[英]Convert IST to EST time zone format
I want to convert my IST datetime to EST datetime.我想将我的 IST 日期时间转换为 EST 日期时间。 I tried a few ways but am unable to do it.我尝试了几种方法,但无法做到。
SELECT (CAST('2022-07-25 03:06' AS DateTime)) at time zone 'US Eastern Standard Time' AS DATETIME
Output: Output:
2022-07-25 03:06:00.000 -04:00 output is same
Required output in EST timezone EST 时区所需的 output
Thanks in advance提前致谢
For offsets between time zones to work correctly you need to start with time zone-aware data types, such as datetimeoffset
.为了使时区之间的偏移正常工作,您需要从时区感知数据类型开始,例如datetimeoffset
。
For example the following parses a time, including time zone offset, into a datetimeoffset
value:例如,以下将时间(包括时区偏移)解析为datetimeoffset
值:
select cast('2022-07-25 03:06:00.000 +5:30' as datetimeoffset) as IST
Which outputs:哪个输出:
IST IST |
---|
2022-07-25 03:06:00.0000000 +05:30 2022-07-25 03:06:00.0000000 +05:30 |
And to convert that to a time in the US EST time zone:并将其转换为美国东部时间时区的时间:
select cast('2022-07-25 03:06 +05:30' AS datetimeoffset) at time zone 'US Eastern Standard Time' as EST
Which outputs:哪个输出:
EST美东时间 |
---|
2022-07-24 17:36:00.0000000 -04:00 2022-07-24 17:36:00.0000000 -04:00 |
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.