TimeZone discrepancy in mysql and java

前端 未结 5 423
生来不讨喜
生来不讨喜 2021-01-18 05:36

I have a query in mysql which compares 2 dates like this

convert_tz(updatedDate,\'+05:30\',\'-05:00\') < ?

the convert function returns

5条回答
  •  再見小時候
    2021-01-18 06:24

    Without seeing the values that are matching on the second query and not on the first, it's hard to be absolutely certain. But one thing to keep in mind is that a time zone is not the same as an offset. Please read "TimeZone != Offset" section of the TimeZone tag wiki.

    For example, you say you are converting to the America/New_York time zone. This zone is sometimes in UTC-05:00 (for Eastern Standard Time), and sometimes in UTC-04:00 (for Eastern Daylight Time). It is entirely possible that some of your data is being picked up because of the -4 offset in effect during daylight savings time.

    When you hardcode to the -5 offset, you are not taking any time zone rules into consideration. Which would explain the discrepancy.

提交回复
热议问题