<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: last day of previous month in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893723#M99249</link>
    <description>corrections.&lt;BR /&gt;&lt;BR /&gt;cal 10||egrep -v '^$|[a-zA-Z]'|head -1|awk '{print $1}' &lt;BR /&gt;cal 10|egrep -v '^$|[a-zA-Z]'|tail -1|awk '{print $NF}'</description>
    <pubDate>Tue, 07 Nov 2006 07:30:04 GMT</pubDate>
    <dc:creator>RAC_1</dc:creator>
    <dc:date>2006-11-07T07:30:04Z</dc:date>
    <item>
      <title>last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893718#M99244</link>
      <description>Hi all,&lt;BR /&gt;    I need to get the last day and first day of previous month.Can you please help me out</description>
      <pubDate>Tue, 07 Nov 2006 06:23:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893718#M99244</guid>
      <dc:creator>viseshu</dc:creator>
      <dc:date>2006-11-07T06:23:36Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893719#M99245</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Since you don't offer what language you want to use (Perl, shell, awk), I'll offer the general outline.&lt;BR /&gt;&lt;BR /&gt;If the current month is one (Januaray=1) then the previous month is twelve (December=12) and its last day is 31.  Exit.&lt;BR /&gt;&lt;BR /&gt;Otherwise subtract one from the current month and using the resulting value, index into an array of days-in-a-month.  If you point to February, do a modulus 4 (year mod 4) and if the result is zero (0) the last day of February is incremeted by one to equal 29. &lt;BR /&gt;&lt;BR /&gt;The first day of any month is a degenerate case --- its simply one (1).  You didn't specify if you wanted the dayname (e.g. Tuesday), etc.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 07 Nov 2006 06:38:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893719#M99245</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-11-07T06:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893720#M99246</link>
      <description>JRF, &lt;BR /&gt;     can you please put it in awk???</description>
      <pubDate>Tue, 07 Nov 2006 06:51:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893720#M99246</guid>
      <dc:creator>viseshu</dc:creator>
      <dc:date>2006-11-07T06:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893721#M99247</link>
      <description>cal 10||grep -v '[a-zA-Z]'|head -1|awk '{print $1}'&lt;BR /&gt;cal 10|grep -v '[a-zA-Z]'|tail -1|awk '{print $NF}'&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Nov 2006 07:20:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893721#M99247</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2006-11-07T07:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893722#M99248</link>
      <description>Hi Viseshu,&lt;BR /&gt;&lt;BR /&gt;for the last day of the previous month, a shell interpretation of mr. Ferguson:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;CURRENT_MONTH=$(date +%m)&lt;BR /&gt;&lt;BR /&gt;case "$CURRENT_MONTH" in&lt;BR /&gt;        01|03|05|07|08|10|12)&lt;BR /&gt;        PREV_LAST=31;;&lt;BR /&gt;        04|06|09|11)&lt;BR /&gt;        PREV_LAST=30;;&lt;BR /&gt;        02)&lt;BR /&gt;        CURRENT_YEAR=$(date +%Y)&lt;BR /&gt;        if [ $(( ${CURRENT_YEAR} % 4)) = 0 ]&lt;BR /&gt;        then&lt;BR /&gt;                PREV_LAST=29&lt;BR /&gt;        else&lt;BR /&gt;                PREV_LAST=28&lt;BR /&gt;        fi;;&lt;BR /&gt;esac&lt;BR /&gt;echo $PREV_LAST&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Tue, 07 Nov 2006 07:26:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893722#M99248</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-11-07T07:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893723#M99249</link>
      <description>corrections.&lt;BR /&gt;&lt;BR /&gt;cal 10||egrep -v '^$|[a-zA-Z]'|head -1|awk '{print $1}' &lt;BR /&gt;cal 10|egrep -v '^$|[a-zA-Z]'|tail -1|awk '{print $NF}'</description>
      <pubDate>Tue, 07 Nov 2006 07:30:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893723#M99249</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2006-11-07T07:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893724#M99250</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Actually, there's a Perl one-liner that will accomodate you.&lt;BR /&gt;&lt;BR /&gt;# perl -MDate::Calc=:all -le '$m=shift;$y=shift;print Days_in_Month($y,$m==1 ? 12:$m-1)' &lt;YEAR&gt; &lt;MONTH&gt;&lt;BR /&gt;&lt;BR /&gt;...that is, pass the year and the current month for which you want the last day of the previous month:&lt;BR /&gt;&lt;BR /&gt;# perl -MDate::Calc=:all -le '$m=shift;$y=shift;print Days_in_Month($y,$m==1 ? 12:$m-1)' 3 2004 &lt;BR /&gt;&lt;BR /&gt;...returns:&lt;BR /&gt;&lt;BR /&gt;29&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;/MONTH&gt;&lt;/YEAR&gt;</description>
      <pubDate>Tue, 07 Nov 2006 08:12:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893724#M99250</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-11-07T08:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: last day of previous month</title>
      <link>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893725#M99251</link>
      <description>Here is a silly, brute-force, yet simple and effective, all awk solution:&lt;BR /&gt;&lt;BR /&gt;--------------------------&lt;BR /&gt;BEGIN {&lt;BR /&gt;t = systime()&lt;BR /&gt;m = strftime("%m", t)&lt;BR /&gt;this_month = m&lt;BR /&gt;while (m == this_month) {&lt;BR /&gt;  t = t - 86400&lt;BR /&gt;  m = strftime("%m", t)&lt;BR /&gt;}&lt;BR /&gt;last_month = m&lt;BR /&gt;print "Last day last month = " strftime("%D", t)&lt;BR /&gt;while (m == last_month) {&lt;BR /&gt;  t = t - 86400&lt;BR /&gt;  m = strftime("%m", t)&lt;BR /&gt;}&lt;BR /&gt;t = t + 86400&lt;BR /&gt;print "First day last month = " strftime("%D", t)&lt;BR /&gt;}</description>
      <pubDate>Tue, 07 Nov 2006 09:22:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/last-day-of-previous-month/m-p/3893725#M99251</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-11-07T09:22:20Z</dc:date>
    </item>
  </channel>
</rss>

