Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing dates in different formats

 
gino jersey
Greenhorn
Posts: 21
  • 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: 3341
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic