简体   繁体   English

MS SQL-时区和DST-使用错误吗?

[英]MS SQL - AT TIME ZONE and DST - Wrong usage?

I have a piece of code like this: 我有一段这样的代码:

Cast('2017-09-02 00:00:00' as datetime)  AT TIME ZONE 'Central Europe Standard Time' 

Output: 输出:

2017-09-02 00:00:00.000 +02:00 2017-09-02 00:00:00.000 +02:00

However, Central Europe Standard Time currently has an offset of +01:00 . 但是,中欧标准时间当前的偏移量为+01:00 So i would expect this output: 所以我期望这个输出:

2017-09-02 00:00:00.000 +01:00 2017-09-02 00:00:00.000 +01:00

Am I using AT TIME ZONE incorrectly? 我在时间区使用不正确吗?

It converts related to the date, not when it is executed 它与日期相关,而不是与日期相关

on 2nd of September it is still DST so +02:00 is correct 9月2日还是DST,所以+02:00是正确的

if you do: 如果您这样做:

Cast('2017-12-02 00:00:00' as datetime)  AT TIME ZONE 'Central Europe Standard Time'  

it will be +01:00 as 2nd of december does not have DST 它将是+01:00,因为12月2日没有DST

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM