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

Home -> Community -> Usenet -> c.d.o.tools -> Re: date format question

Re: date format question

From: Cristian Palma <cristian.palma_at_sage.cl>
Date: Wed, 16 May 2001 20:29:49 -0400
Message-ID: <3B031B7D.CA4A9064@sage.cl>

I would say that this form can help you ...

(the example is with sysdate)

select   to_char(sysdate,'ss')
       + to_char(sysdate,'mi')*60
       + to_char(sysdate,'dd')*60*60
       + decode(to_char(sysdate,'mm'), 1,31
                                     , 2,31+28
                                     , 3,31+28+31
                                     , 4,31+28+31+30
                                     , 5,31+28+31+30+31
                                     , 6,31+28+31+30+31+30
                                     , 7,31+28+31+30+31+30+31
                                     , 8,31+28+31+30+31+30+31+31
                                     , 9,31+28+31+30+31+30+31+31+30
                                     ,10,31+28+31+30+31+30+31+31+30+31
                                     ,11,31+28+31+30+31+30+31+31+30+31+30

,12,31+28+31+30+31+30+31+31+30+31+30+31)*24*60*60
       + (to_char(sysdate,'yyyy')-1970)*((7*31+4*30+1*28)*24*60*60)
from dual;

(note: the "leap" years* (is that correct?) are not considerated, but you could
 adjust the query in order to include them ...)

*: years with 29 days in february ... I found leap in a dictionary :-)

Zhiliang Hu wrote:

> How to format an Oracle date to be shown as the number of seconds since
> 1970?

>

> Thanks!

>
> Zhiliang
--
Received on Wed May 16 2001 - 19:29:49 CDT

Original text of this message

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