【发布时间】:2022-02-12 21:35:38
【问题描述】:
select (convert(datetime ,SWITCHOFFSET(CONVERT(datetimeoffset, '2022-02-11 11:15:00.000'),
(select current_utc_offset FROM sys.time_zone_info where name ='Singapore Standard Time')
))) CurrentTime
我怎样才能达到低于预期的效果?
当前结果:
CurrentTime
-----------------------
2022-02-11 19:15:00.000
预期结果:
CurrentTime
-----------------------
2022-02-11 03:15:00.000
PS:我不能在脚本中使用-8 或-08:00。
【问题讨论】:
-
为什么不能在脚本中使用
-8或-08:00?有什么原因吗? -
select convert(datetime , cast('2022-02-11 11:15:00.000' as datetime) at time zone 'Singapore Standard Time' at time zone 'utc') CurrentTime -
@lptr 工作正常。谢谢!
-
@D-Shih 这是需求的一部分。谢谢!
标签: sql-server tsql datetime timezone datetime-conversion