Hi Folks
I need some routines to get the following dates from any given day of the month :
Last day of the previous month
Last day of the month before previous month
I am using the following routines which breaks for leap year
($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime();
$month += 1;
$year += 1900;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$mon = $mon + 1; $year = $year + 1900;
my $last_day;
my $previous_month = $month - 1;
if ($previous_month == 0){$previous_month = 12; $year = $year - 1; $last_day = 31;}
elsif ($previous_month == 2) {$last_day = 28;}
elsif ($previous_month == 2 and $day == 29) {$last_day = 29;}
elsif ($previous_month == 4) {$last_day = 30;}
elsif ($previous_month == 6) {$last_day = 30;}
elsif ($previous_month == 9) {$last_day = 30;}
elsif ($previous_month == 11) {$last_day = 30;}
else {$last_day = 31;}
Thanks for you help
Brenda
I need some routines to get the following dates from any given day of the month :
Last day of the previous month
Last day of the month before previous month
I am using the following routines which breaks for leap year
($sec,$min,$hour,$mday,$month,$year,$wday,$yday,$isdst) = localtime();
$month += 1;
$year += 1900;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$mon = $mon + 1; $year = $year + 1900;
my $last_day;
my $previous_month = $month - 1;
if ($previous_month == 0){$previous_month = 12; $year = $year - 1; $last_day = 31;}
elsif ($previous_month == 2) {$last_day = 28;}
elsif ($previous_month == 2 and $day == 29) {$last_day = 29;}
elsif ($previous_month == 4) {$last_day = 30;}
elsif ($previous_month == 6) {$last_day = 30;}
elsif ($previous_month == 9) {$last_day = 30;}
elsif ($previous_month == 11) {$last_day = 30;}
else {$last_day = 31;}
Thanks for you help
Brenda