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: Good question on dates

Re: Good question on dates

From: Joel R. Kallman <jkallman_at_us.oracle.com>
Date: Fri, 25 Feb 2000 12:45:06 GMT
Message-ID: <38b678be.4477027@newshost.us.oracle.com>


From page 2-17 of the Oracle8i SQL Reference manual:



You can add and subtract number constants as well as other dates from dates. Oracle interprets number constants in arithmetic date expressions as numbers of days. For example, SYSDATE + 1 is tomorrow. SYSDATE - 7 is one week ago. SYSDATE + (10/1440) is ten minutes from now. Subtracting the HIREDATE column of the EMP table from SYSDATE returns the number of days since each employee was hired. You cannot multiply or divide DATE values.

In your case, simply take the number of hours divided by 24 and add this to your date column.

"SELECT SYSDATE + 2/24 FROM DUAL" will be 2 hours from now.

Hope this helps.

On Wed, 23 Feb 2000 22:06:19 GMT, argosy22_at_my-deja.com wrote:

>Hello all,
>
>We have a new spec, and it's got a good skill
>testing question in it. We are using Oracle 7.3.4.
>
>We have a date field, and a number field.
>The number field indicates a number of hours.
>
>We need to combine these two to get a new date.
>(date + hours = new_date). (That date will then
>be compared to another date.)
>
>I've looked at the built in Oracle functions.
>There is the add_months() and next_day() functions.
>But that is not what I'm looking for.
>
>this gives:
>
>Select to_char(sysdate, 'DDD:HH24') Doy_hoD
>FROM DUAL
>
>DOY_HOD
>--------------
>054:16
>
>
>Is there a way to add these two fields together
>into a date in a simple manner? Or, do you think
>that I will have to write a complex function to do this?
>
>Thanks,
>
>Argosy
>
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

Thanks!

Joel

Joel R. Kallman Oracle Service Industries

Columbus, OH                             http://govt.us.oracle.com

jkallman@us.oracle.com                   http://www.oracle.com




The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation. Received on Fri Feb 25 2000 - 06:45:06 CST

Original text of this message

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