Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL Removing weekends
Hi Helen,
the to_char() function with 'DY' format returns the 3 char name of the day for the given date:
select to_char(sysdate, 'DY') fro dual;
would return 'WED' on my machine.
so if you wanna count the SATs and SUNs between two given dates try this one:
select count(*)
from your_table
where your_date_field between to_date('01-JAN-2000', 'DD-MON-YYYY') and
sysdate
and to_char(your_date_field, 'DY') in ('SAT', 'SUN');
that should return you the count of SATs and SUNs between 1 Jan 2k and todays date.
HTH
ATTA
In article <8s0f5k$5s8$1_at_nnrp1.deja.com>,
helen267_at_my-deja.com wrote:
> 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.
>
-- getting the meanin' of data... Sent via Deja.com http://www.deja.com/ Before you buy.Received on Wed Oct 11 2000 - 00:00:07 CDT
![]() |
![]() |