Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Data Types
 

Using TIMESTAMP WITH TIME ZONE

You cannot store time zone into DATE datatype. You can explicitly store the time zone for TIMESTAMP datatypes, as shown here: declare     variable1_ts TIMESTAMP[(precision)] WITH TIME ZONE; begin     NULL; end; / SQL> SQL> --You can see these values yourself by using the built-in functions DBTIMEZONE and SESSIONTIMEZONE. SQL> SQL> declare   2      v_ts TIMESTAMP(6) WITH TIME ZONE :=CURRENT_TIMESTAMP;   3      v_tx VARCHAR2(2000);   4  begin   5      v_tx:=to_char(v_ts,'HH24:MI:SS.FF6 TZR');   6      DBMS_OUTPUT.put_line(v_tx);   7      v_tx:=to_char(v_ts,'TZH TZM');   8      DBMS_OUTPUT.put_line(v_tx);   9  end;  10  / 20:32:41.890000 -07:00 -07 00 PL/SQL procedure successfully completed. SQL>