getdate() to east time

  • hello

    someone aware how to convert getdate() to at time zone EASTERN TIME

    can you help me please

    • This topic was modified 5 years, 2 months ago by  samirca007.
  • SELECT getdate() AT TIME ZONE 'Eastern Standard Time';

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • You should be using SYSDATETIMEOFFSET() if you are going to be switching time zones.

    SELECT GETDATETIMEOFFSET() AT TIME ZONE 'US Eastern Standard Time'

    If you need to, you can then convert that to a DATETIME value.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Jeffrey Williams wrote:

    SELECT getdate() AT TIME ZONE 'Eastern Standard Time';

    This will only work if the local time IS Eastern Standard Time.  If the input date doesn't already have an offset, it assumes that the input date is the value at the target time zone rather than the value at the local time zone that needs to be adjusted to the target time zone.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply