#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Kitchener, Ontario, Canada
    Posts
    31
    Rep Power
    14

    Grabbing date...


    I am trying to grab todays date to do the following, I am building a query to use on an Oracle database and my two options are:

    1) All dates less than or equal to today

    2) Todays

    I am curious how I can get a current date that can also be used in this query...

    The date format in the database is like so:

    2001-10-10 00:00:00.0
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Location
    Dublin, Ireland
    Posts
    0
    Rep Power
    0
    This is tricky for a number of reasons, the main on being that the java.util.Date class is completely different from the java.sql.Date class. Therefore it is much easier to use a timestamp.

    The following will get you the current Timestamp:

    // get the current date as TimeStamp
    long now = System.currentTimeMillis();
    Timestamp nowTS = new Timestamp(now);

    Now you can refer to this in your SQL statement to get less than or equal to.

    .:bar:.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Kitchener, Ontario, Canada
    Posts
    31
    Rep Power
    14
    I actually figured this out and when I go back to work on Monday I will post my solution...

IMN logo majestic logo threadwatch logo seochat tools logo