• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date comparision in SQL from timestamp

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...???
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic