Click here to Skip to main content
15,314,526 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:

I think i know the answer but i just wanted second opinion.

An application i have writes to a database from a VM, the datetime stamps appear to go in using UTC time - so currently in UK the clocks went back 1 hour for daylight savings time

so an 8am entry goes in at 7am however i have another application that pulls information out of the database but showing out of sync using an extractor i wrote using sql.

so my question here is:
Does 'GetUTCTime()' function always return the base time without daylight savings time as i need to make the change now but i dont want it to mess up when the clocks go back again, i am using this to adjust the timestamp on the SQL select statement.

Please can you confirm if it will do the trick when the clocks go back, it works now that we are in DST.

		WHEN DATEDIFF(HOUR, GetUtcDate(), GetDate()) = 1 
		THEN CONVERT(datetime, '01:00:00',120) 
		ELSE CONVERT(datetime, '00:00:00',120) 

1 solution

GetUTCDate returns, not suprisingly, UTC :) (aka GMT, Zulu, TZ0 etc) - it's normally 'best practice' to have SQL store and return UTC, and have the *client* app interpret that to local time, avoids lots of problems, and makes all times 'sensible'
Dev O'Connor 11-May-15 6:24am

Unfortunately the front end applications are out of our control in terms of the way they process data, we just have a SQL file that it is used by the receiving application to get data from the first application.

So currently we are +01:00 due to DST, UTC is +00:00 currently, i assume on 25th October 2015 when UK DST reverts, the SQL i used above will use the other CASE: 00:00:00

Appreicate you responding.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900