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

Re: How to find the last date of the previous month?

by Anonymous Monk
on Oct 30, 2012 at 10:44 UTC ( #1001483=note: print w/replies, xml ) Need Help??

in reply to How to find the last date of the previous month?


1. Find the epoch at 00.00 hrs for Date 1 of current month, current year.

2. Subtract 1 from that to reach previous day and convert that epoch again into date.

3. Grab the date and/or month value from it.

#!/usr/bin/perl -w use strict; use Class::Date; my $date = new Class::Date [`date +%Y`, `date +%m`, 1, 0, 0, 0]; my $curMonthEpoch = $date->epoch; my $prevMonthEpoch = $curMonthEpoch - 1; print "Last Date of Prev Month=".`date --date='\@$prevMonthEpoch' +%d` +;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001483]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2016-10-26 14:11 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (341 votes). Check out past polls.