Daylight Savings time question

  • 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?  

  • 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

  • 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.

  • 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?

  • 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