This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing dates in different formats

 
gino jersey
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to compare dates in different formats.
In the table the field (let's call it revoke_date) is defined as a Date type, and data is stored like 02-Dec-2005.

The application sends in data to the JSP in mm/dd/yyyy format, stored in variable vDate, type String.

How can I do soemthin like "select * from tbl1 where revoke_date = vDate"
properly?

Thank you.
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by gino jersey:
(let's call it revoke_date) is defined as a Date type, and data is stored like 02-Dec-2005.


No, no database that I know of stores a date like that, it displays it that way when you look at the data, however every DB I know of stores this as a number value, the number of millisecs (Or whatever it uses, Oracle now uses NanoSec) after an epoc date

Every DB has a function that allows dates to be converted to a Varchar in whatever format you want.

In Oracle this would be
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic