Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Days between two days
In article <ae8gqj$4sdq7$1_at_ID-68406.news.dfncis.de>,
"James Alexander Starritt" <james_at_jamesstarritt.com> wrote:
> Any ideas how to work out the number of days between two dates in a select
> query?
>
set serveroutput on
set feedback off
set verify off
var daycount integer;
accept vday1 char prompt "Enter the EARLIEST date (format: MM/DD/YY): "; accept vday2 char prompt "Enter the LATEST date (format: MM/DD/YY): ";
BEGIN
SELECT to_date('&&vday2','MM/DD/YY') - to_date('&&vday1','MM/DD/YY')
INTO :daycount
FROM DUAL;
DBMS_OUTPUT.PUT_LINE(' The number of days between &&vday1 and &&vday2 is
'||:daycount);
END;
/
Try it.
-- The underscore character does not belong in my address. You know the drill... *** Anyone sufficiently smart enough to configure and use USEnet for research should be smart enough to Read The Freakin' Documentation!Received on Wed Jun 12 2002 - 17:38:17 CDT