Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: how to change dates or times in a oracle date time field
> Jim,
> To do that you simply add an integer to the field....the integer
> represents the number of DAYS..so,
>
> SYSDATE + 3 will add three days to SYSDATE, SYSDATE - 3 subtracts
> three days etc...
>
> To get hours, minutes, seconds etc you divide a day into it's
> components (24 hours in a day for instance) so,
>
> SYSDATE + 1/24 adds an hour, SYSDATE + 1/24/60 adds a minute etc..
>
> Therefore to add 8 minutes as in your example you would use SYSDATE +
> 8/24/60
Everything correct so far, except that 1/24/60 is no INTEGER.
Consider:
set serveroutput on
alter session set nls_date_format = 'dd.mm.yyyy hh24:mi:ss';
declare
i integer;
f number;
d date;
begin
d := '29.05.1999 12:01:01';
i := 8/24/60;
f := 8/24/60;
dbms_output.put_line ('add integer: ' || to_char(d + i)); dbms_output.put_line ('add number : ' || to_char(d + f));
end;
/
Didn't mean to be picky but wanted to make sure someone who learns pl/sql is aware of the difference between integers and numbers (or floats).
Rene Received on Wed Jun 19 2002 - 16:37:38 CDT
![]() |
![]() |