We help IT Professionals succeed at work.

How to tell dailight savings time in SQL Server

quiTech asked
Last Modified: 2008-02-01
Is there a way to tell whether a specific date falls within daylight savings time from a stored procedure inside SQL Server 2000?

The reason I ask is this.  I have a third party application that records time stamps in "number of seconds since '31-Dec-1969 17:00'".  This is based on our time zone (MST -7).  In actual fact, it's "number of seconds since '1-Jan-1970 0:00'".  

The problem is that when I conver this to human readable form using dateadd(ss,timestamp,'31-Dec-1969 17:00'), it only works accurately during standard time.  As soon as daylight savings time hits, it's off by an hour.

Does anyone have any suggestions how to deal with this?

Thanks in advance!
Watch Question

You need to cater for daylight savings time yourself. Best place to do this is actually on the front-end. Record (in the database) the start and end period of daylight savings, and the adjustment. On the UI, adjust each date accordingly.

Alternatively, you can make this adjustment in SQL, but with the overhead of returning a calculated value for each date (necessary or not) the UI is probably the best bet.
This one is on us!
(Get your first solution completely free - no credit card required)


Perfect!!! Thanks folderol.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.