I have the date column in datetimeoffset format.
2016-01-09 05:49:06.3744350 +00:00
Run Code Online (Sandbox Code Playgroud)
I want to convert it to only date format, e.g. 2016-01-09.
I was able to convert datetimeoffset to datetime2 with this query.
convert(datetime2, sampleDate, 1) as date
Run Code Online (Sandbox Code Playgroud)
Would be much obliged if I could know how to convert this to the desired format in MS SQL.
Simply:
SELECT CONVERT(DATE, CONVERT(DATETIMEOFFSET, '2016-01-09 05:49:06.3744350 +00:00'))
Run Code Online (Sandbox Code Playgroud)
Returns:
2016-01-09
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4546 次 |
| 最近记录: |