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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Add hours and minutes to date

RE: Add hours and minutes to date

From: Kevin Lange <kgel_at_ppoone.com>
Date: Tue, 31 Jul 2001 09:38:37 -0700
Message-ID: <F001.0035A5B9.20010731094608@fatcity.com>

Add the hour field converted to a number divided by 24 plus the minute field converted to a number divided by (24*60)

For example:

declare
num_hours varchar2(10) := '24';
num_mins varchar2(10) := '10';
date_field date := sysdate;
new_date_field date := null;
begin
new_date_field := date_field +
(to_number(num_hours)/24+to_number(num_mins)/(60*24));

dbms_output.enable(20000);
dbms_output.put_line(num_hours);
dbms_output.put_line(num_mins);
dbms_output.put_line(to_char(date_field,'YYYY-MM-DD-HH24.MI.SS'));
dbms_output.put_line(to_char(new_date_field,'YYYY-MM-DD-HH24.MI.SS'));
end;
/

-----Original Message-----
Sent: Tuesday, July 31, 2001 11:31 AM
To: Multiple recipients of list ORACLE-L

I have 2 varchar2 variables, one containing a number of hours and the other containing a number of minutes, which I want to add to a date variable.

How can I do this?

John

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: John Dunn
  INET: john.dunn_at_sefas.co.uk

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Kevin Lange
  INET: kgel_at_ppoone.com
Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Tue Jul 31 2001 - 11:38:37 CDT

Original text of this message

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