-1

Could you please explain how come (YYYY-MM-DD hh:mm:ss {+|-}hh:mm) format is having 26 characters in datetimeoffset datatype in SQL Server? Is there is a space between hh:mm:ss  and {+|-}hh:mm?

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • 3
    Databases store date/time values using internal formats. They are converted to strings for presentation purposes. Your question doesn't make sense. – Gordon Linoff Oct 24 '17 at 11:52

1 Answers1

1

Yes, there is a space at position 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]

Results:

value                               | length | 27th character | 27th character ascii
2017-10-24 09:18:36.0466667 +00:00  |  34    |                | 32
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
rrozema
  • 325
  • 1
  • 7