Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Date Conversion Function Localtime to UTC (Java Wrapper)

RE: Date Conversion Function Localtime to UTC (Java Wrapper)

From: Christian Antognini <Christian.Antognini_at_trivadis.com>
Date: Wed, 11 May 2005 10:19:18 +0200
Message-ID: <7F0C000A3ABA6241A10C9ABF37EEB46D040855@MSXVS01.trivadis.com>


Hi Andreas

>I'm looking for 2 functions like this:
>
> FUNCTION local2UTC(iDATE IN DATE)
> RETURN DATE IS
> -- Returns UTC for iDATE in localtime
> BEGIN
> ...
> END;
>
>and the inverse function
>=3D20
> FUNCTION UTC2local(iDATE IN DATE)
> RETURN DATE IS
> -- Returns localtime for iDATE in UTC
> BEGIN
> ...
> END;
Just some thoughts...=20

If the timezone is correctly configured on your machine with a select = like the following you get the difference between your local time and = GMT: SQL> SELECT tz_offset(dbtimezone) FROM dual;

TZ_OFFS



+01:00

If this is the case you could use the following select to do a = conversion of the local time to GMT:

SQL> SELECT cast(sysdate AS TIMESTAMP) local,

  2         from_tz(cast(sysdate AS TIMESTAMP), tz_offset(dbtimezone))
  3         AT TIME ZONE 'GMT' gmt

  4 FROM dual;
LOCAL                          GMT
------------------------------ ------------------------------
11-MAY-05 10.15.57.000000      11-MAY-05 09.15.57.000000 GMT


HTH
Chris

--
http://www.freelists.org/webpage/oracle-l
Received on Wed May 11 2005 - 04:24:04 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US