문제

According to the MSSQL documentation when calling convert with style 127 (ISO8601 with time zone Z) the output should be expected to look like yyyy-mm-ddThh:mi:ss.mmmZ.

But executing the following SQL will will output the same value (without Z) regardless of style 126 or 127

SELECT convert(nvarchar(64), GetUtcDate(), 127), convert(nvarchar(64), GetUtcDate(), 126)

Am I reading the documentation wrong? The first column should end with Z indicating UTC timezone, shouldn't it? Using MSSQL 2012.

도움이 되었습니까?

해결책

Since you're on 2012, you can use FORMAT instead:

SELECT FORMAT(GetUtcDate(),'yyyy-MM-dd HH:mm:ss.fffzzz')

Which produced, a short time ago:

2014-05-13 08:23:29.093+01:00

(Or, you could use 'yyyy-MM-dd"T"HH:mm:ss.fffzzz' if you want the T separator instead of space)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top