Oracle 时区(TimeZone ) 时区转换

不同时区的查询

select n.tzname, n.tzabbrev, tz_offset(n.tzname) from v$timezone_names n;


不同时区的转换方法

时区转换的语法 at time zone

select systimestamp, systimestamp at time zone sessiontimezone from dual;

select from_tz(to_timestamp('2008/03/28 16:00:00'), '+08:00') at time zone '-07:00' from dual;

select to_timestamp_tz('2008/03/28 16:00:00 +08:00') at time zone 'US/Mountain' from dual;

-- 如果仅仅转换到UTC (GMt),使用 sys_extract_utc
 select systimestamp,
       sys_extract_utc(systimestamp) utc,
       (to_timestamp_tz(to_char(systimestamp)) at time zone '00:00') manually_utc
  from dual;

作者:wait4friend
Weibo:@wait4friend
Twitter:@wait4friend
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/wait4friend/p/2345454.html