【问题标题】:Convert UTC timestamp to AEDT in Oracle to consider daylight saving在 Oracle 中将 UTC 时间戳转换为 AEDT 以考虑夏令时
【发布时间】:2020-12-10 02:29:34
【问题描述】:

从 UTC 转换为 AEST(澳大利亚东部标准时间)不考虑夏令时,因为它现在是 +11 小时,但此脚本仍然转换为 10 小时:

Select from_tz (cast(DateField as TIMESTAMP),'UTC') at Time Zone 'Australia/Sydney' as AEST

有没有什么直观的方法可以让它在夏季工作 11 小时,在冬季工作 10 小时,而无需创建函数并对其进行硬编码?

【问题讨论】:

    标签: oracle timezone


    【解决方案1】:

    不确定您如何确定您的公式“不考虑夏令时”。它在我的系统上。请注意,date 文字假定时间是午夜。然后比较:

    select from_tz (cast(datefield as timestamp),'UTC') 
           at time zone 'Australia/Sydney' as aest
    from   ( select date '2020-07-31' as datefield from dual union all
             select date '2020-12-15'              from dual
           )
    ;
            
    AEST                                
    ------------------------------------
    2020-07-31 10:00:00 Australia/Sydney
    2020-12-15 11:00:00 Australia/Sydney
    

    显然,Oracle 知道“夏季”和“冬季”时间之间的差异(DST 调整)。

    【讨论】:

      猜你喜欢
      • 2014-06-01
      • 2015-08-04
      • 1970-01-01
      • 2018-01-27
      • 2012-05-01
      • 1970-01-01
      • 2021-08-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多