<?xml version="1.0" encoding="windows-1252"?>
<node id="1001450" title="Re: How to find the last date of the previous month?" created="2012-10-29 23:26:57" updated="2012-10-29 23:26:57">
<type id="11">
note</type>
<author id="968231">
Athanasius</author>
<data>
<field name="doctext">
&lt;p&gt;Here is one way:&lt;/p&gt;

&lt;code&gt;
#! perl
use strict;
use warnings;
use Date::Calc qw(Days_in_Month Today);

print 'The last day of last month was ', last_day_last_month(), "\n";

sub last_day_last_month
{
    my ($year, $month, $day) = Today([time]);

    if (--$month == 0)
    {
        $month = 12;
        --$year;
    }

    return sprintf("%02d/%d/%d", $month,
                                 Days_in_Month($year, $month),
                                 $year);
}
&lt;/code&gt;

&lt;p&gt;Hope that helps,&lt;/p&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-968231"&gt;
&lt;p&gt;Athanasius&amp;emsp;&lt;font color=#008000&gt;&amp;lt;&amp;deg;(((&amp;gt;&amp;lt;&lt;/font&gt;&amp;emsp;&lt;i&gt;contra mundum&lt;/i&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1001445</field>
<field name="parent_node">
1001445</field>
</data>
</node>
