Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL Removing weekends
declare
vdate date;
vdnum number;
wkend number := 0;
begin
select adate into vdate
from mikejunk where rownum = 1;
s_output.put_line(
'Weekend days between ' ||
to_char( vdate, 'mm/dd/yyyy') ||
' and ' ||
to_char( sysdate, 'mm/dd/yyyy'));
while vdate <= sysdate loop
select to_char( vdate, 'd'),
vdate+1
into vdnum,
vdate
from dual;
if vdnum = 1 or vdnum = 7 then
wkend := wkend + 1;
end if;
end loop;
dbms_output.put_line( ' is: ' || to_char( wkend));
end;
/
adate is a date column = '30-SEP-00'.
<helen267_at_my-deja.com> wrote in message news:8s0f5k$5s8$1_at_nnrp1.deja.com...
> Hi there
>
> I'm trying to write a simple PL/SQL script (for a stored procedure)
> that will count the number of weekend days, i.e Saturday and Sunday,
> that occur between two dates. I thought I had it right, but I can't
> for the life of me work out why it's not working!
>
> Has anyone done anything similar and could help me out, either by
> checking the script I have so far, or writing a quick solution?
>
> Thanks in advance
>
> Helen
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Oct 12 2000 - 09:15:10 CDT
![]() |
![]() |