Karthi
Karthi

Reputation: 708

Date conversion using SQL - SQL Server

I need to convert the date format from YYYY-MM-dd to yyyy-MM-dd'T'HH:mm:ss.SSSZ using SQL Server 2008. Any hint or sugggestion will be greatly helpful.

Upvotes: 1

Views: 67

Answers (2)

Giorgi Nakeuri
Giorgi Nakeuri

Reputation: 35780

Just cast to datetime type:

SELECT CAST('2015-05-28' AS DATETIME)

Upvotes: 2

TTeeple
TTeeple

Reputation: 2989

You can achieve this using CONVERT.

SELECT CONVERT(datetime, '2015-05-28', 127)

Returns 2015-05-28 00:00:00.000

Use this page as a reference for future conversions: https://msdn.microsoft.com/en-us/library/ms187928.aspx

Upvotes: 5

Related Questions