Getdate() function to get date for my timezone

后端 未结 5 1046
执念已碎
执念已碎 2021-01-05 05:49

I would love to insert a default value into a column with data type datetime2(7). However, because my website is hosted on a server in a different timezone, the getdate func

5条回答
  •  醉梦人生
    2021-01-05 06:14

    SELECT GETDATE() AT TIME ZONE 'UTC' AT TIME ZONE 'Central Standard Time'
    

    You need the first 'AT TIME ZONE UTC' in order to tell the DB what the value currently is in, so it knows how to get to the second given time zone, 'Central Standard Time' in my example.

提交回复
热议问题