Jump to content


Photo

convert varchar date field to datetime


  • Please log in to reply
1 reply to this topic

#1 matte

matte
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 17 October 2006 - 04:15 PM

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!!!!




#2 Skraaningen

Skraaningen
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 October 2006 - 10:11 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users