Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to sum minutes to date

Re: How to sum minutes to date

From: Hans Forbrich <forbrich_at_yahoo.net>
Date: Thu, 01 Apr 2004 12:30:19 GMT
Message-ID: <vXTac.3572$dW5.3182@edtnps89>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US