March 12, 2007 at 2:34 pm
I need to modify a statement in a proc to get data for the day up to 9pm Pacific Time. We are in Arizona and don't do Daylight Saving time - so I can't just do a -1 hour. I could code the days that we go into DST into an IF statement and set the proper time there, but that could be a maintenance problem if the DST dates were to change. I am aware of the getdateUTC, but can't work out how to do it since there (as I understand it) separate zones such as PST and PDT and I would have to do the same hard coding of the change dates. Currently the time is just being changed by programmers here . Am I misunderstanding this? Any tips?
March 13, 2007 at 6:30 am
The solution that we have is a database that contains all of the date/times that Daylight Saving Time changes for each time zone. There is one record for each time zone for each year. All data is stored in UTC. Any call to retrieve data then runs through a function which determines the offset to the local time.
If you are only working with one time zone it is pretty easy. Write a function that checks to see if the time needs DST applied or not and return that value.
Scott
March 13, 2007 at 7:17 am
I agree with Scott on the function thing. I'd use a function as it would work well and I'd put the time zones in a table. You can use UTC or local time and put the offset in a table.
Give people some parameter to the function which specifies the time zone and return the time using your table.
March 13, 2007 at 8:00 am
I agree with the above however, keep in mind that some states are in more than one time zone. How are you making the time determination? Do you only have state, or is a telephone number or zipcode available?
March 13, 2007 at 9:16 am
It's really only between LA and Phoenix, so it shouldn't be to hard. Thanks for the info - just wondered of there was a clever way to do it that I was missing
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply