Ron Hill wrote:
> 
> Actually I run the reports on the first of the
month for the previous
> month so I had to do this
> my $month = DateTime->today->truncate( to =>
'month' )->subtract( months =>1);
> 
> > 
> >    $dt_span = DateTime::Span->from_datetimes(
> >                 start =>  $month->clone,
> >                 before => $month->add( months => 1 ),
> >               );
> > 

This one behaves better - it doesn't change $month value:

  my $this_month = 
      DateTime->today->truncate( to => 'month' ); 

  my $previous_month_span = 
      DateTime::Span->from_datetimes(
               start =>  $this_month->clone
                           ->subtract( months => 1),
               before => $this_month,
      );
 
- Flavio S. Glock


Reply via email to