Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: How to sum minutes to date
Max wrote:
> Hi all,
> I need to sum x minutes to a date. Ex. the value I select is '01/01/2004
> 12:30' and I need to sum '20' minutes so to obtain '01/01/2004 12:50'.
> How could I do? I not find in Oracle 9i a function to sum time.
> Thanks in advanced
The '+' operator is 'overloaded' for date arithmetic. However it needs units of 'days' to work.
Easiest way to handle this is convert your increment to a fraction of a day. Remembering that there are nominally 24 hours = 1440 minutes (etc) in a day, 20 minutes = 20/1440 of a day.
new_value = date_value + 20/1440
This is explained in the SQL Reference manual in the section about datatypes (iirc there is a discussion about date arithmetic). The doc is at http://docs.oracle.com
HTH
/Hans
Received on Thu Apr 01 2004 - 06:30:19 CST