|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Saturday, August 18, 2012 10:37 AM
Points: 5,
Visits: 80
|
|
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?
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Wednesday, May 08, 2013 5:30 AM
Points: 870,
Visits: 522
|
|
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)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 5:16 AM
Points: 1,196,
Visits: 1,319
|
|
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
|
|
|
|