How to calculate the local datetime from a utc datetime in tsql (sql 2005)?

前端 未结 10 1370
Happy的楠姐
Happy的楠姐 2021-02-02 14:13

i want to loop over a period of time in tsql, and print the utc datetimes and our local variant. We live in UTC +1, so i could easily add 1 hour, but in the summertime we live i

10条回答
  •  盖世英雄少女心
    2021-02-02 15:02

    GETUTCDATE() just gives you the current time in UTC, any DATEADD() you do to this value will not include any daylight savings time shifts.

    Your best bet is build your own UTC conversion table or just use something like this:

    http://www.codeproject.com/KB/database/ConvertUTCToLocal.aspx

提交回复
热议问题