| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.tools -> Re: date format question
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?
>
--Received on Wed May 16 2001 - 19:29:49 CDT
![]() |
![]() |