omacron
Technical User
- Feb 5, 2002
- 149
Hi
I am try to compare a VARCHAR field that stores a date as:
MMDDYYYY
To a date time field. So what I am doing is running a script like this;
select
TransactionID,
DateTimeField,
VarCharDate
from Table
where
to_char(DateTimeField, 'MM-DD-YYYY') <> to_char(to_date((VarCharDate), 'MM-DD-YYYY'), 'MM-DD-YYYY')
The problem is that some times when the date is in the future this doesn't work. For example lets say that DateTimeField = 08-29-2009 04:15:23
When doing this: to_char(DateTimeField, 'MM-DD-YYYY') it returns this;
08-29-2008
Why is this happening or is there an easier way of comparing this.
I am try to compare a VARCHAR field that stores a date as:
MMDDYYYY
To a date time field. So what I am doing is running a script like this;
select
TransactionID,
DateTimeField,
VarCharDate
from Table
where
to_char(DateTimeField, 'MM-DD-YYYY') <> to_char(to_date((VarCharDate), 'MM-DD-YYYY'), 'MM-DD-YYYY')
The problem is that some times when the date is in the future this doesn't work. For example lets say that DateTimeField = 08-29-2009 04:15:23
When doing this: to_char(DateTimeField, 'MM-DD-YYYY') it returns this;
08-29-2008
Why is this happening or is there an easier way of comparing this.