Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date first and last day of week given week and year

Status
Not open for further replies.

jdbolt

Programmer
Aug 10, 2005
89
CA
Hi,

I need a way to get the last and first day of teh week given a week and year number, 45 (week) and 2005 (year) for example.

Could any provide insight into how this might be done?
 
yeah I have that module installed, I was hoping someone could give me some ideas on how to solve the problem,
 
Have you read the docs for the modules?

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
use Date::Calc qw:)all);
use Date::Calendar;

($year,$month,$day) = Today();
my ($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime time;
$year += 1900;
$mon++;
$week = int(($day + Day_of_Week($year,$month,1) - 2) / 7) + 1;
$dow = Day_of_Week($year,$month,$day);
$DayOfWeek = Day_of_Week_to_Text($dow);

Example:
($month == 11 && $week == 4 && $DayOfWeek eq "Thursday") && do{ # Thanksgiving Day

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top