G'day devbond,
"i need to find the first day of the first week of a month."
Firstly, that seems an odd way to ask this. I'm assuming, for a given year and month, you want to know what day (e.g. Sunday) the 1st of that month is. If that's not what you meant, please clarify.
There's a plethora of modules on CPAN that can do this type of thing; however, the builtin module, Time::Piece, can also do this and you already have it installed. So, unless you're already using some Date::*, Time::*, etc. module, Time::Piece is probably your best choice. Here's sample code:
#!/usr/bin/env perl -l use strict; use warnings; use Time::Piece; # In 2 days it will be Tuesday, 1st October 2013 my $month = 10; my $year = 2013; my $day_name = Time::Piece->strptime("$year$month" . '01', '%Y%m%d')-> +fullday; print "01-Oct-2013 is a $day_name";
Output:
01-Oct-2013 is a Tuesday
-- Ken
In reply to Re: How to find first day of the first week on the month?
by kcott
in thread How to find first day of the first week on the month?
by devbond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |