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

Home -> Community -> Usenet -> c.d.o.tools -> Re: PL/SQL Removing weekends

Re: PL/SQL Removing weekends

From: Helen A <hell_at_ihug.co.nz>
Date: Thu, 12 Oct 2000 11:17:42 +1300
Message-ID: <8s2p87$66h$1@news.ihug.co.nz>

Thanks for your reply, unfortunately that's not exactly what I'm trying to do (I should have explained myself better). Your solution will count the number of rows in the table, where the your_date_field is between 01-JAN-2000 and sysdate.

I've got a table similar to this:

ID
START_DATE
END_DATE
NO_WEEKEND_DAYS (blank)

For each row in the table, I want to calculate the number of weekend days between START_DATE and END_DATE, and update the NO_WEEKEND_DAYS with that number. I've been playing around with loop statements etc. but still no joy.

Any ideas?

Helen

--
____________________________
Atta ur-Rehman <atta707_at_my-deja.com> wrote in message
news:8s0s4m$fpd$1_at_nnrp1.deja.com...

> 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 - 17:17:42 CDT

Original text of this message

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