Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
I have two columns datetimeUTC (DateTime) and Offset (nvarchar(5)). What is the most effective way of provding a new datetime (DateTime) in SQL 2005 for the client to display?datetimeUTC Offset Expected Result8/02/2009 11:00:00 AM 0 8/02/2009 11:00:00 AM8/02/2009 11:00:00 AM +2:00 8/02/2009 1:00:00 PM8/02/2009 11:00:00 AM -2:00 8/02/2009 9:00:00 AM8/02/2009 11:00:00 AM +2:30 8/02/2009 1:30:00 PM9/02/2009 11:00:00 PM +2:00 10/02/2009 1:00:00 AM10/02/2009 1:00:00 AM -2:00 9/02/2009 11:00:00 PMI can store the Offset in any datatype, maybe best as bigint then stored in seconds?Thanks
So if it was as below how do we handle the offset calculation:datetimeUTC Offset Expected Result8/02/2009 11:00:00 AM 0 8/02/2009 11:00:00 AM8/02/2009 11:00:00 AM +120 8/02/2009 1:00:00 PM8/02/2009 11:00:00 AM -120 8/02/2009 9:00:00 AM8/02/2009 11:00:00 AM +150 8/02/2009 1:30:00 PM9/02/2009 11:00:00 PM +120 10/02/2009 1:00:00 AM10/02/2009 1:00:00 AM -120 9/02/2009 11:00:00 PM
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2009-02-08 : 00:52:31
The maximum offset is -12 hours or + 12 hours, which is 720 minutes.Use SMALLINT and as tkizer wrote, minutes is enough.There are some parts of the world that changes offset to an half of an hour (30 minutes) during summer time. These countries mostly reside in the Middle East.E 12°55'05.63"N 56°04'39.26"
tonymorell10
Yak Posting Veteran
90 Posts
Posted - 2009-02-08 : 01:08:57
You can either add a computed column to the table or perform the calculation dynamically in a query: