# Determine weekends and compare two days

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
I'm not much of a perl programmer so I was hoping someone could help
me. What I need to do is determine between 2 dates whether there is a
weekend between them inclusive.

eg Between 1 Oct 2004 and  4 Oct 2004 there is a Sat. and a Sunday but
between 5 Oct 2004 and 8 Oct 2004, there is no Sat or Sunday.

Prak

## Re: Determine weekends and compare two days

> I'm not much of a perl programmer so I was hoping someone could help
> me. What I need to do is determine between 2 dates whether there is a
> weekend between them inclusive.
>
> eg Between 1 Oct 2004 and  4 Oct 2004 there is a Sat. and a Sunday but
> between 5 Oct 2004 and 8 Oct 2004, there is no Sat or Sunday.
>
> Prak

You really ought to try working this one out on your own! That way you'll
understand and improve. Here's a pointer.

use Time::localtime;
my \$today = time;
my \$day_of_week = localtime(\$today)->wday;
my @days_of_week = qw(Sun Mon Tues Wed Thur Fri Sat);
print"Today is \$days_of_week[\$day_of_week]\n";