Jump to content
SSMITH001

Date in a string field

Recommended Posts

Help! I can't figure this out...

I have a date value stored in a VARCHAR(2) field called RFRC_NUM10. In my where clause, I want to grab all records where this date value is >= sysdate, but I can't seem to get it to work. 

AND TO_DATE(RFRC_NUM10,'YYYY-MM-DD') >= TO_CHAR(sysdate, 'YYYY-MM-DD')

Share this post


Link to post
Share on other sites

Hi, and welcome to the forum!

First, I would add a DATE column to the table, copy the VARCHAR data into

it, drop the VARCHAR column and rename the new DATE column to the old VARCHAR column name.

If you look st your query, you are trying to compare a DATE (via the to_date function) to a character.

This is a data type mis-match!

Remove to to_char from the sysdate and try it again, comparing date to date!

Good luck!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×