SQL Server / SQL中datetimeoffset数据类型的字符长度是多少?

时间:2017-10-24 11:50:57

标签: sql sql-server datetimeoffset

请问您能解释一下(YYYY-MM-DD hh:mm:ss {+|-}hh:mm)格式在SQL Server中的datetimeoffset数据类型中有26个字符吗? hh:mm:ss{+|-}hh:mm之间是否有空格?

1 个答案:

答案 0 :(得分:1)

是的,28号位置有一个空格:

declare @o datetimeoffset;

select @o = getdate()

select 
    @o as [value], 
    len(convert(varchar(36), @o)) as [length],
    substring(convert(varchar(36), @o), 28, 1) as [27th character],
    ascii(substring(convert(varchar(36), @o), 28, 1)) as [27th character ascii]

结果:

value                               | length | 27th character | 27th character ascii
2017-10-24 09:18:36.0466667 +00:00  |  34    |                | 32