matte Posted October 17, 2006 Share Posted October 17, 2006 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!!!! Quote Link to comment https://forums.phpfreaks.com/topic/24228-convert-varchar-date-field-to-datetime/ Share on other sites More sharing options...
Skraaningen Posted October 21, 2006 Share Posted October 21, 2006 Convert(Datetime, String,103) should do it. 103 support the dd/mm/yyyy date formatLook up MSSQL help on CONVERT to find other date formats. Quote Link to comment https://forums.phpfreaks.com/topic/24228-convert-varchar-date-field-to-datetime/#findComment-112492 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.