November 28, 2011 at 3:58 pm
Hi All,
I want to display records for past hour using GMT time... I'm currently using the below syntax to get previous hour records.But I dont want to define any value..Can anyone help me on this??
DateAdd (hh, -12, getdate())
-12 hours for Summer and -11 hours for Winter
November 28, 2011 at 5:08 pm
Look at the function GETUTCDATE() for example
SELECT GETUTCDATE(),GETDATE()
Results
--GETUTCDATE GETDATE
2011-11-29 00:03:56.0002011-11-28 19:03:56.003
Here is a good discussion for you to read:
http://sqlserverperformance.wordpress.com/2007/04/25/one-way-to-convert-from-utc-time-to-local-time/
Is this what you are looking for ? If not post back and some else may assist you.
November 28, 2011 at 10:11 pm
Thanks for your reply.
I applied below syntax to get the result:
dateAdd(hour,(datediff(hour, getdate(),getutcdate())-1), getdate())
I also wanted to get UTC today's midnight datetime ...How do i get that??
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply