我有一个这样的查询:
select from_tz(to_timestamp(v_time,'YY-MM-DD HH24:MI:SS'), 'UTC')
at time zone 'America/New_York' from dual;
如果我使用字符串 Date 而不是 v_time 那么它工作正常。但是我需要在 to_timestamp 中传递一个变量 v_time,我该怎么做呢?
提前致谢。
完整代码在这里:
DECLARE
v_test varchar2(200);
v_cur_time varchar2(200);
v_local_strem_time varchar2(200);
v_time varchar2(200);
v_time_diff NUMBER(20);
v_temp varchar2(200);
BEGIN
SELECT TO_CHAR(SYSDATE, 'DD-MON-YY HH24:MI:SS') into v_cur_time
FROM DUAL;
select substr(((select TO_CHAR(date_time,'YY-MM-DD HH24:MI:SS') from observation_measurement where observation_measurement_id=5777992)), 1,17)
into v_time from dual;
v_temp := v_time;
select from_tz(to_timestamp(v_temp,'YY-MM-DD HH24:MI:SS'), 'UTC')
at time zone 'America/New_York' into v_local_strem_time from dual;
select 24 * (to_date(v_cur_time, 'YY-MM-DD HH24:MI:SS')
- to_date(v_local_strem_time, 'YY-MM-DD HH24:MI:SS')) into v_time_diff
from dual;
DBMS_OUTPUT.PUT_LINE(v_time_diff);
END;