How to get last hour records using GMT time....

  • 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

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

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • 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