Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a varchar datatype to datetime

Status
Not open for further replies.

djtom2000

Programmer
Feb 2, 2002
13
0
0
GB
I have a varchar datatype within a table that is storing a date. Due to a problem the field had to be varchar. I have now got round the problem and need to change the datatype to datetime. When I try this it will not let me and I get the error 'Unable to convert char to datetime'. How do I get round this?

Thanks
 

Use the Convert function and a style number to convert a varchar column from a specific date style to datetime data type.

Convert(datetime, chardate, 3)

3 is the dd/mm/yy style (British/French)

See details in SQL BOL under the topic Cast and Convert. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top