in reply to Re: perl script to calculate beg and end of current month
in thread perl script to calculate beg and end of current month

Hi, I download this scirpt and ran it. It seems like set_day(1) is not working as expected. Currently, the first variable is showing as first=2008-06-30 instead of 2008-06-01. Let me know if there any workaround to fix this. Any help would be appreciated. -- Ace28
  • Comment on Re^2: perl script to calculate beg and end of current month

Replies are listed 'Best First'.
Re^3: perl script to calculate beg and end of current month
by Anonymous Monk on Nov 09, 2009 at 05:24 UTC
    This is how I managed to have the above code work.
    use DateTime; $dt = DateTime->today(); my $mnth = $dt->subtract(months => 1); my $first = $mnth->clone->set_day(1); my $last = $first->clone->add( months => 1 )->subtract( days => 1 ); print "first=$first last=$last\n";