This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes SQL Current Time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Current Time" Watch "SQL Current Time" New topic

SQL Current Time

Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Hi all,

Is it possible to get a time stamp in SQL in the format of a long datatype similar to the java Method System.currentTimeMillis() .

I know sql has functions similar to SELECT NOW(); which return something like "2009-06-05 16:10:09" , but i would like to hava a method to return it as a long number. As i have saved alot of my time instances in the database as long numbers and now i have the need to do a select based on the current time and instance of a saved long number. I dont think a SELECT statement would work if i tried something like SELECT .... WHERE (SELECT NOW()) < column.TimeMillisAsLong.

Mark Hughes
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

What wrong with:

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 146
Thanks Paul i did not think of that, very good. Ill give it a go.

Mark Hughes
I agree. Here's the link:
subject: SQL Current Time
Similar Threads
Code review
DataInputStream and DataOutputStream in Jar file (no need to reply now)
Another question about Widening and Boxing
B&S: How do I get the "new" recNo?
Building an Internal DSL?