Adjust dates based on timezone

  • Does anyone know of a good function that allows us to change time stamps based on timezone. I've go a DB that is in EST, but I need to report the times in the users local timezone (AZT). To add a curve, the users local timezone does not adjust to DST, so we need to make sure we adjust for that. I could not find anything in the standard library.

  • If you are running on SQL2K:

    --Convert Local to UTC

    select DATEADD( MINUTE, DATEDIFF( MINUTE, GETDATE(), GetUTcDate()), <Local Time>)

    --Convert UTC to Local

    select DATEADD(MINUTE, DATEDIFF(MINUTE, GetUTCDate(), GETDATE()), <UTC Time>)

    Store the value in the database as Universal Time. Convert the time at the client side. In theory, this allows insertion from anywhere with a valid presentation anywhere else.

    Guarddata-

Viewing 2 posts - 1 through 1 (of 1 total)

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