Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is date/time part of SQL Server's datetimeoffset UTC or local?

According to Microsoft's page on the datetimeoffset data type (see here):

A time zone offset specifies the zone offset from UTC for a time or datetime value.

But nowhere does it say whether the datetime part of the datetimeoffset string literal format is showing either:

  • UTC time, with the timezone offset being what to apply to that time to get to localtime, or;
  • localtime, with the timezone offset being what to apply to that time to get back to UTC.

This is the string literal format for datetimeoffset: YYYY-MM-DD hh:mm:ss[.nnnnnnn] [{+|-}hh:mm].

My question therefore is, is the YYYY-MM-DD hh:mm:ss[.nnnnnnn] bit of that string literal in localtime or in UTC?

like image 568
Nick Shaw Avatar asked Dec 01 '11 15:12

Nick Shaw


1 Answers

The YYY-MM-DD hh:mm:ss[.nnnnnnn] [{+|-}hh:mm] format is an ISO8601 format. The ISO page gives

Coordinated universal time (UTC)
Local time with offset to UTC

As this format has the offset then the base time is local. See wikipedia for other examples.

like image 194
mmmmmm Avatar answered Nov 15 '22 08:11

mmmmmm