getdate() to east time

  • samirca007

    Old Hand

    Points: 367

    hello

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

    can you help me please

    • This topic was modified 1 month ago by  samirca007.
  • Jeffrey Williams 3188

    SSC Guru

    Points: 88150

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

    [font="Verdana"]Jeffrey Williams
    Problems are opportunities brilliantly disguised as insurmountable obstacles.

    How to post questions to get better answers faster[/url]
    Managing Transaction Logs[/url]
    [/font]

  • drew.allen

    SSC Guru

    Points: 76634

    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

  • drew.allen

    SSC Guru

    Points: 76634

    Jeffrey Williams 3188 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 4 (of 4 total)

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