Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

The SQL Server 2008 Datetimeoffset Data Type Expand / Collapse
Author
Message
Posted Monday, April 18, 2011 3:25 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 7:18 PM
Points: 56, Visits: 1,038
mtassin (4/18/2011)
Make a table...
.
.
.
INSERT the daylight savings start and stop times plus the offset to use.
.
.
.
Now JOIN to this table
.
.
.



Of course if you operate in more than one country (or even in more than one state in Australia - don't know if everywhere in the US has the same DST rules), this table would get way more complicated where you have different places with different DST rules.... You'd have to add in a time zone name column too, which would then also need to get stored along with your datetimeoffset value in every table where you want to use the information - back to needing two columns to store your time data.

Having a 'DST' bit in the datetimeoffset type would be the best resolution. I would have thought they could add a bit quite easily - perhaps an extra bit of 'precision'.
Post #1095328
Posted Monday, April 18, 2011 9:17 PM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, July 3, 2014 9:19 PM
Points: 605, Visits: 1,691
Thanks for the article. My only suggestion is that I think you might have made a stronger point by using 'hour' for your DATEDIFF examples as timezone differences are [usually] measured in hours. But otherwise I think you did good by raising awareness of this feature.

It's worth mentioning that another 2008 feature, Data Collection, stored its results in UTC time. This threw me at first until I dug into the schema and then BOL'd datetimeoffset. I'd much rather have known about this earlier. (I was writing my own reports, btw. Not meaning to suggest that the Data Collection reports themselves are UTC time.)

As to daylight savings time being a consideration for functions, I fear this would be too unwieldy. There's a lot of different start-end dates for these, including many 'one-off' examples (ie: the Sydney 2000 Olympics garnered an extended DS period for just that year) and it would be a job in itself to maintain that system.


Steve.
Post #1095393
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse