cobolstinks
cobolstinks

Reputation: 7143

SQL Server datetime convert

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

Answers (2)

Lamak
Lamak

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

sll
sll

Reputation: 62504

SELECT CAST('2010-09-04' as DateTime)

returns 2010-09-04 00:00:00.000

Sql Server 2008

Upvotes: 3

Related Questions