Detect if a date is in Daylight saving time in MySql

前端 未结 4 614
失恋的感觉
失恋的感觉 2021-01-25 09:32

I have inherited a legacy application where all the dates and times are stored in the local timezone (UK). I am not in a position to change how these are stored.

Howeve

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-25 10:13

    found an ugly complicated way, @DT is input Date&Time

    Set @DT=20150329020304; # -> 0
    
    Set @DT=20150329030304; # -> 1(-0.0511)
    
    Set @DT=20150329040304; # -> 1(-1)
    
    Select 0!=(UNIX_TIMESTAMP(@DT)-   UNIX_TIMESTAMP(Concat(Year(@DT),'0101',Time_Format(@DT,'%H%i%s')))-DateDiff(@DT,Concat(Year(@DT),'0101',Time_Format(@DT,'%H%i%s')))*86400)/3600 as DlsIsOn
    

提交回复
热议问题