Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


The SQL Server 2008 Datetimeoffset Data Type


The SQL Server 2008 Datetimeoffset Data Type

Author
Message
Ryan C. Price
Ryan C. Price
Valued Member
Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)Valued Member (72 reputation)

Group: General Forum Members
Points: 72 Visits: 1179
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'.
Fal
Fal
Mr or Mrs. 500
Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)Mr or Mrs. 500 (526 reputation)

Group: General Forum Members
Points: 526 Visits: 1803
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.
Iwas Bornready
Iwas Bornready
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10106 Visits: 885
James A Skipwith (4/18/2011)
Good point Mark, Date would be better here as the time portion is irrelevant. I don't tend to store many dates like this but the Date data type would be preferred over Datetime.
Most of our dates (and we have plenty) don't care about time, such as the date range that someone is covered for a particular service. The few cases where we use datetime are for fields like the last time the record was touched or when the record was created.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search