How do I convert the current time (datetime) in my timezone into another timezone, say France ? I looked around in SO, but did not find any posts which could help me. I am using SQL server 2008.
问问题
31363 次
3 回答
8
select CONVERT(datetime,SWITCHOFFSET(CONVERT(datetimeoffset,GetUTCDate()),'+05:30')) Date_India,
select CONVERT(datetime,SWITCHOFFSET(CONVERT(datetimeoffset,GetUTCDate()),'+03:30')) Date_Iran
于 2013-10-30T20:06:36.383 回答
2
请用 GetUTCDate() 替换 getdate() 以获得准确的结果,否则这种情况下的偏移量 (5:30) 将被添加到当前时间(已经有一些偏移量)并导致不正确的结果。
例如,如果你在巴基斯坦,那么 GetDate() 会给你的时间为 GMT+5:00,在这个时间加上 5:50 的偏移量将导致 GMT + 10:30,这是完全错误的。
于 2014-12-23T06:42:58.600 回答