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