Reputation: 3349
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.
Upvotes: 3
Views: 7250
Reputation: 239764
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)
Upvotes: 5