wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes comparing dates in different formats Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "comparing dates in different formats" Watch "comparing dates in different formats" New topic
Author

comparing dates in different formats

gino jersey
Greenhorn

Joined: May 24, 2005
Posts: 21
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

Joined: Jun 13, 2000
Posts: 3340
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


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
Don't get me started about those stupid light bulbs.
 
subject: comparing dates in different formats