October 15th, 2001, 01:24 PM
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
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:
October 24th, 2001, 06:51 PM
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.
October 25th, 2001, 09:40 AM
I actually figured this out and when I go back to work on Monday I will post my solution...