Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to get last month date period

by youlose (Scribe)
on Mar 04, 2010 at 18:32 UTC ( #826777=note: print w/replies, xml ) Need Help??


in reply to How to get last month date period

use DateTime;
use Modern::Perl;
my $fdm = DateTime->now->subtract(months=>1)->truncate(to=>'month');
my $ldm = DateTime->last_day_of_month(year=>$fdm->year,month=>$fdm->month);
my $stf_pat = '%d %b %Y';
say $fdm->strftime($stf_pat),' - ',$ldm->strftime($stf_pat);

Replies are listed 'Best First'.
Re^2: How to get last month date period
by kivilahtio (Initiate) on Dec 22, 2014 at 09:51 UTC
    Sweet! A beautiful solution.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://826777]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-03-24 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (298 votes). Check out past polls.