April 19, 2010 at 2:44 am
Hi,
I havve a table with a column dateofbirth that is stored as Varchar.
It has values like 02/25/2009, March 23rd 2008, and Wednesday April 2nd 2009.
I need to convert this column to data type datetime.
Any idea that can assist?
April 19, 2010 at 2:54 am
Please look into the following ones
If the varchar contains Day [Mon or tue..etc] or rd/nd/th [2nd ,12th,23rd] it doesnt allow to use cast ...
SELECT CAST ('02/25/2009' as DATETIME)
SELECT CAST ('March 23 2008' as DATETIME)
SELECT CAST ('April 2 2009' as DATETIME)
April 19, 2010 at 3:27 am
You may have to strip out the 'nd', 'rd' from April 2nd, April 3rd etc using REPLACE.
See CAST AND CONVERT in MSDN for a full description
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply