PLSQL中的时区转换 [英] Timezone conversion in PLSQL
本文介绍了PLSQL中的时区转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将sysdate和时间转换为EST等特定时区.我不能假设我当前的时区.
I need to convert the sysdate and time to a particular timezone like EST. I can't assume my current time zone.
如何在plsql中转换它?请帮我.
How to convert this in plsql? Please help me.
推荐答案
假设您有TIMESTAMP WITH TIME ZONE
(例如systimestamp
),则可以使用AT TIME ZONE
语法.例如,我可以通过指定不同的时区名称来获取当前的systimestamp
并将其转换为UTC(GMT),东部和太平洋时区.
Assuming you have a TIMESTAMP WITH TIME ZONE
(such as systimestamp
), you can use the AT TIME ZONE
syntax. For example, I can take the current systimestamp
and convert it to UTC (GMT), Eastern, and Pacific time zones by specifying different time zone names.
SQL> ed
Wrote file afiedt.buf
1 select systimestamp at time zone 'UTC' current_time_in_utc,
2 systimestamp at time zone 'Us/Eastern' current_time_in_est,
3 systimestamp at time zone 'US/Pacific' current_time_in_pst
4* from dual
SQL> /
CURRENT_TIME_IN_UTC
---------------------------------------------------------------------------
CURRENT_TIME_IN_EST
---------------------------------------------------------------------------
CURRENT_TIME_IN_PST
---------------------------------------------------------------------------
26-APR-12 05.36.11.802000 PM UTC
26-APR-12 01.36.11.802000 PM US/EASTERN
26-APR-12 10.36.11.802000 AM US/PACIFIC
这篇关于PLSQL中的时区转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文