> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 02, 2001 3:46 AM
> To: [EMAIL PROTECTED]
> Subject: more on date counting
> 
> 
> Hi 
> I am trying to work out how to determine how many days are 
> between a set 
> of dates excluding weekends..
> 
> So far I have figured out how to subtract one date from the 
> other, see 
> below.
> 
> The next section I would like help with is the bit that 
> figures out how to 
> ignore dates that are weekends.
> 
> 
> use Date::Calc qw(:all); 
> $mon = (1..12) [(localtime)[4]]; 

This is very inefficient. Why not just (localtime)[4]+1 ?

> $yr=1900+$year; 

Where did $year come from?

> $wdays = (0..6) [(localtime)[6]]; 

This is no different from just (localtime)[6]. It is also
day of the WEEK, but Delta_Days below needs day of MONTH.

> $day1 = 26; 
> 
> 
> $Dd = Delta_Days($yr,$nmon,$day1, $yr,$mon,$wdays); 
> print $Dd; 

Anyway, assuming you can get $Dd to correctly reflect total
days between the two dates, here's the algorithm I would use:

$Dd represents some whole number of weeks (0 or more), plus
a partial week of 0-6 days. Find the whole number of weeks
and multiply by 5, since each week has 5 non-weekend days.

For the partial week ends on the week day of your ending
date, working backwards, add 1 to the total for each day
of this partial week which is not a weekend day.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to