Reputation: 7143
I need to convert these varchars
to datetime
. I've been to the microsoft page and don't see a style that is applicable to this format.
How would you convert these to datetime?
Format: yyyy-mm-dd
Example data: 2010-09-04
Thanks a lot
Upvotes: 0
Views: 174
Reputation: 70638
I would recommend that you specify the format of the date, in your case, 120.
SELECT CONVERT(DATETIME,'2010-09-04',120)
Upvotes: 1
Reputation: 62504
SELECT CAST('2010-09-04' as DateTime)
returns 2010-09-04 00:00:00.000
Sql Server 2008
Upvotes: 3