| Author |
Date comparision in SQL from timestamp
|
Nicolas Flammel
Ranch Hand
Joined: May 05, 2004
Posts: 32
|
|
How to compare a Timestamp returned from Java code 2004-06-11 00:00:01.0 in a query in Oracle to a date value 2004-06-11 00:00:00.0 in the table . I have used select id from table where TIME between to_date('2004-06-09 00:00:00','yyyy-mm-dd hh:mi:ss') and to_date('2004-06-11 00:00:00','yyyy-mm-dd hh:mi:ss') I get a message that hour can be between 1 and 12. But I want to check the time for midnight. How to format the date in SQL query...???
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
Use HH24 instead of HH in your format string. It's all in the Oracle documentation. But really, why don't you simply use PreparedStatement? That allows you to sidestep the entire date format minefield (and similarly for Strings, it allows you to sidestep the escape character minefield). - Peter
|
 |
 |
|
|
subject: Date comparision in SQL from timestamp
|
|
|