Jump to content

Archived

This topic is now archived and is closed to further replies.

matte

convert varchar date field to datetime

Recommended Posts

hello everyone,

i am creating a search function that searches the table for records greater than today.  However in the database the dates are stored as varchar(10) as 10/17/2006 in column DATECOLUMN.  I am trying to use the convert function to convert the date into datetime so i can compare to current date time. 

WHERE CONVERT(datetime, DATECOLUMN) > GETDATE()

i think the problem is the date isn't in the correct format for the datetime... as it should be 20061017.  Does anyone know how i could format the DATECOLUMN to use the convert function or another way of doing so?

Thanks VERY much!!!!


Share this post


Link to post
Share on other sites
Convert(Datetime, String,103) should do it. 103 support the dd/mm/yyyy date format
Look up MSSQL help on CONVERT to find other date formats.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.