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

Home -> Community -> Usenet -> c.d.o.server -> Re: How convert a unix time stamp (time_t) to Oracle Date datatype

Re: How convert a unix time stamp (time_t) to Oracle Date datatype

From: Jurij Modic <jurij.modic_at_mf.sigov.mail.si>
Date: Wed, 13 May 1998 21:13:35 GMT
Message-ID: <355a0cf5.3234817@www.sigov.si>


On Wed, 13 May 1998 17:30:11 +0200, "Aymeric Barantal" <abaranta_at_grolier.fr> wrote:

>Hello everyone,
>
>I want to convert a date express in second since 1st january of 1970 (time_t
>on Unix system) to an oracle date datatype.
>
>Is there a procedure to do that, or how can I do.

Date datatype is additive, the basic unit of date arithmetics is 1 day, that is 24*60*60 seconds.

So you just have to add the corresponding number of days as an offset from the starting date ('01-JAN-70').

Example:
SELECT TO_DATE('01-JAN-70','DD-MON-YY')+&seconds_from_1970/(24*60*60) FROM dual;

This will return the date, corresponding to the date expressed as the number of seconds (&seconds_from_1970) from the 01-JAN-1997.

Using this date arithmetics you can create your own function that will accept the number_of_seconds_from_1970 as an imput parameter and will return the coresponding date.

>Thank for your help.
>
>-- aymeric barantal -- Paris France

Regards,


Jurij Modic                             Republic of Slovenia
jurij.modic_at_mf.sigov.mail.si		Ministry of Finance
============================================================
The above opinions are mine and do not represent any official standpoints of my employer Received on Wed May 13 1998 - 16:13:35 CDT

Original text of this message

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