Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: Date/time arithmetics with Oracle Server
In article <3773B16D.BC7465C2_at_xlink.net>,
Uwe Schneider <uwe.schneider_at_xlink.net> wrote:
> Hi experts,
>
> is there an easy way to add or subtract a number of seconds to/from
an
> Oracle date type such as
>
> ADD_SECONDS(date_val,-20)
>
> without using special packages???
>
> In my opinion the Oracle DATE type is quite strange.
>
> Best regards!
> --
> uwe.schneider_at_xlink.net
>
To answer your question:
UAT1> l
1 select to_char(sysdate,'yyyymmdd hh24:mi:ss') now,
2 to_char(sysdate + ( 20 / 86400 ),'yyyymmdd hh24:mi:ss')
"now+20sec"
3* from sys.dual
UAT1> /
NOW
Oracle performs addition and substraction to a date in units of days so there are 86400 seconds to a day hince hours, minutes, and seconds may be represented as a fraction of a day. There was a recent thread on calculating the difference in time between two days which you may want to hunt for. If you can not find it I would be glad to e-mail you the couple of queries/functions that users posted that I copied to study.
--
Mark D. Powell -- The only advice that counts is the advice that
you follow so follow your own advice --
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Fri Jun 25 1999 - 13:07:09 CDT