Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Subtract Hours From A Given Date
On Fri, 10 Sep 1999 09:00:45 -0400, you wrote:
>Harvey wrote:
>
>> Does anyone know how to subtract hours from a given datetime in Oracle?
>>
>> Is there a function similar to add_months?...ie ADD_MONTHS(sysdate,-6) will
>> return a date 6 months before the current date.
>
>To subtract 5 hours:
>
>select to_char(sysdate,'YYYYMMDD HH24:MI:SS'),
> to_char(to_date(to_number(to_char(sysdate,
> 'JSSSSS')) -
> (60 * 60 * 5),'JSSSSS'),'YYYYMMDD HH24:MI:SS')
>
>from dual;
>
>
or
select (sysdate - 5/24) from dual
--
See http://govt.us.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri Sep 10 1999 - 08:18:08 CDT
![]() |
![]() |