Allain Lalonde
Allain Lalonde

Reputation: 93348

How can I convert a varchar field of the form: YYYYMMDD to a datetime in T-SQL?

How can I convert a varchar field of the form YYYYMMDD to a datetime in T-SQL?

Thank you.

Upvotes: 7

Views: 38735

Answers (2)

JGW
JGW

Reputation: 69

Use the CONVERT() function?

http://msdn.microsoft.com/en-us/library/ms187928.aspx

Upvotes: 0

bobwienholt
bobwienholt

Reputation: 17610

select convert(datetime, '20081030')

Upvotes: 20

Related Questions