我想将IST日期时间转换为EST日期时间。我尝试了几种方法,但都做不到。
SELECT (CAST('2022-07-25 03:06' AS DateTime)) at time zone 'US Eastern Standard Time' AS DATETIME
输出:
2022-07-25 03:06:00.000 -04:00 output is same
EST时区所需输出
提前感谢
要使时区之间的偏移量正常工作,您需要从具有时区意识的数据类型开始,例如datetimeoffset
。
例如,以下将时间(包括时区偏移(解析为datetimeoffset
值:
select cast('2022-07-25 03:06:00.000 +5:30' as datetimeoffset) as IST
哪个输出:
IST |
---|
2022-07-25 03:06:00.0000000+05:30 |