==========================================================
create or replace function utc_from_oracle (date_in in date) return number is
begin
return (date_in-to_date('01.01.70','dd.mm.rr'))*(60*60*24);
end;
/
==========================================================
create or replace function utc_to_oracle (utc_in in number) return date is
begin
return to_date('01.01.70','dd.mm.rr')+(utc_in/(60*60*24));
end;
/
==========================================================
Here are proofs-of-concept using your values:
SQL> col a heading "UTC values to Oracle Dates" format a65
SQL> select '"'||create_time||'" in UTC value = "'||
2 to_char(utc_to_oracle(create_time),'yyyy-mm-dd hh24:mi:ss')||
3 '" in Oracle date.' a
4 from utc_values
5 /
UTC values to Oracle Dates
-----------------------------------------------------------------
"1063887715" in UTC value = "2003-09-18 12:21:55" in Oracle date.
"1063888362" in UTC value = "2003-09-18 12:32:42" in Oracle date.
"1063888896" in UTC value = "2003-09-18 12:41:36" in Oracle date.
"1063886482" in UTC value = "2003-09-18 12:01:22" in Oracle date.
"1063889897" in UTC value = "2003-09-18 12:58:17" in Oracle date.
"1063890021" in UTC value = "2003-09-18 13:00:21" in Oracle date.
"1063890134" in UTC value = "2003-09-18 13:02:14" in Oracle date.
7 rows selected.
SQL> col b heading "Oracle Dates to UTC values" format a65
SQL> select '"'||to_char(ODate,'yyyy-mm-dd hh24:mi:ss')||
2 '" in Oracle date = "'||utc_from_oracle(ODate)||'" in UTC value.' b
3 from Oracle_dates;
Oracle Dates to UTC values
-----------------------------------------------------------------
"2003-09-18 12:21:55" in Oracle date = "1063887715" in UTC value.
"2003-09-18 12:32:42" in Oracle date = "1063888362" in UTC value.
"2003-09-18 12:41:36" in Oracle date = "1063888896" in UTC value.
"2003-09-18 12:01:22" in Oracle date = "1063886482" in UTC value.
"2003-09-18 12:58:17" in Oracle date = "1063889897" in UTC value.
"2003-09-18 13:00:21" in Oracle date = "1063890021" in UTC value.
"2003-09-18 13:02:14" in Oracle date = "1063890134" in UTC value.
7 rows selected.
SQL>