 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Determine last day of previous month</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/</link>
	<description></description>
	<lastBuildDate>Tue, 21 May 2013 20:11:10 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: cwc</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/#comment-71696</link>
		<dc:creator>cwc</dc:creator>
		<pubDate>Wed, 16 Dec 2009 16:08:39 +0000</pubDate>
		<guid isPermaLink="false">#comment-71696</guid>
		<description><![CDATA[I think the the latter two solutions are preferrable since they utilize RPG IV&#039;s built in date handling, which leaves less room for error.  BigKat, your way looks pretty bullet proof.  

Regarding leap years, for anyone who&#039;s interested, I recommend going beyond the simple divide by 4 logic, as it will not work in the year 2100.  Yes, few of us here today will be around then, but similar logic will likely still be in use in whatever form it exists then.  I know there will be plenty of false leap year determinations in 2100.  

The additional rule is that for years ending in 00, they must be evenly divisible for 400 in order to be a leap year.  Thus, 2000 was a leap year, but 1900 was not, and 2100, 2200, and 2300 will not be.]]></description>
		<content:encoded><![CDATA[<p>I think the the latter two solutions are preferrable since they utilize RPG IV&#8217;s built in date handling, which leaves less room for error.  BigKat, your way looks pretty bullet proof.  </p>
<p>Regarding leap years, for anyone who&#8217;s interested, I recommend going beyond the simple divide by 4 logic, as it will not work in the year 2100.  Yes, few of us here today will be around then, but similar logic will likely still be in use in whatever form it exists then.  I know there will be plenty of false leap year determinations in 2100.  </p>
<p>The additional rule is that for years ending in 00, they must be evenly divisible for 400 in order to be a leap year.  Thus, 2000 was a leap year, but 1900 was not, and 2100, 2200, and 2300 will not be.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jbmm</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/#comment-71677</link>
		<dc:creator>jbmm</dc:creator>
		<pubDate>Wed, 16 Dec 2009 07:43:51 +0000</pubDate>
		<guid isPermaLink="false">#comment-71677</guid>
		<description><![CDATA[basically, it&#039;s the first day of current month - 1 day 
always right

without the coding, in easy words:
date (01 + current month + current year) - 1 day]]></description>
		<content:encoded><![CDATA[<p>basically, it&#8217;s the first day of current month &#8211; 1 day<br />
always right</p>
<p>without the coding, in easy words:<br />
date (01 + current month + current year) &#8211; 1 day</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bigkat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/#comment-54145</link>
		<dc:creator>bigkat</dc:creator>
		<pubDate>Tue, 24 Jun 2008 14:13:14 +0000</pubDate>
		<guid isPermaLink="false">#comment-54145</guid>
		<description><![CDATA[if you always want the previous month-end date whenever you run the program, use this:

&lt;pre&gt;
d wrkdate         s               d                    
 /free                                                 
      wrkdate = %date() - %days(%subdt(%date():*days));
      dump(a);                                         
      *inlr = *on;                                     
 /end-free                                             
&lt;/pre&gt;

otherwise, replace &lt;i&gt;%date()&lt;/i&gt; with the date you want to find the previous month-end date for.

Kevin C. Ketzler - &lt;a href=&quot;http://www.aresgrp.com&quot;&gt;Affiliated&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>if you always want the previous month-end date whenever you run the program, use this:</p>
<pre>
d wrkdate         s               d                    
 /free                                                 
      wrkdate = %date() - %days(%subdt(%date():*days));
      dump(a);                                         
      *inlr = *on;                                     
 /end-free                                             
</pre>
<p>otherwise, replace <i>%date()</i> with the date you want to find the previous month-end date for.</p>
<p>Kevin C. Ketzler &#8211; <a href="http://www.aresgrp.com">Affiliated</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gilly400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/#comment-54143</link>
		<dc:creator>gilly400</dc:creator>
		<pubDate>Tue, 24 Jun 2008 13:50:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-54143</guid>
		<description><![CDATA[Whoops,

That first &quot;C LastMonth WhenEq 1&quot; should be &quot;C LastMonth WhenEq 2&quot;, but then you guys already knew that, right.

Regards,

Martin.]]></description>
		<content:encoded><![CDATA[<p>Whoops,</p>
<p>That first &#8220;C LastMonth WhenEq 1&#8243; should be &#8220;C LastMonth WhenEq 2&#8243;, but then you guys already knew that, right.</p>
<p>Regards,</p>
<p>Martin.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gilly400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/#comment-54142</link>
		<dc:creator>gilly400</dc:creator>
		<pubDate>Tue, 24 Jun 2008 13:48:46 +0000</pubDate>
		<guid isPermaLink="false">#comment-54142</guid>
		<description><![CDATA[Hi,

The last day of the month is in essence a constant dependent on which month it is and whether or not it&#039;s a leap year, so you could hard-code for this :-

&lt;pre&gt;
     C     CurrentMonth  Sub       1             LastMonth         2 0
     C                   Select                                       
     C     LastMonth     WhenEq    1                                  
     C     Year          Div       4             Dummy             5 0
     C                   Mvr                     LeapYear          1 0
     C     LeapYear      IfNe      *Zeros                             
     C                   Z-add     28            DayNumber            
     C                   Else                                         
     C                   Z-add     29            DayNumber            
     C                   Endif                                        
     C     LastMonth     WhenEq    1                                  
     C     LastMonth     Oreq      3                                  
     C     LastMonth     Oreq      5                                  
     C     LastMonth     Oreq      7                                  
     C     LastMonth     Oreq      8                                  
     C     LastMonth     Oreq      10                                 
     C     LastMonth     Oreq      12                                 
     C                   Z-add     31            DayNumber            
     C     LastMonth     WhenEq    4                                  
     C     LastMonth     Oreq      6                                  
     C     LastMonth     Oreq      9                                  
     C     LastMonth     Oreq      11                                 
     C                   Z-add     30            DayNumber            
     C                   EndSl      
&lt;/pre&gt;

This isn&#039;t a perfect solution (if you can divide the year by 4, it&#039;s not *always* a leap year), but it should work for most situations.

Regards,

Martin Gilbert.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>The last day of the month is in essence a constant dependent on which month it is and whether or not it&#8217;s a leap year, so you could hard-code for this :-</p>
<pre>
     C     CurrentMonth  Sub       1             LastMonth         2 0
     C                   Select                                       
     C     LastMonth     WhenEq    1                                  
     C     Year          Div       4             Dummy             5 0
     C                   Mvr                     LeapYear          1 0
     C     LeapYear      IfNe      *Zeros                             
     C                   Z-add     28            DayNumber            
     C                   Else                                         
     C                   Z-add     29            DayNumber            
     C                   Endif                                        
     C     LastMonth     WhenEq    1                                  
     C     LastMonth     Oreq      3                                  
     C     LastMonth     Oreq      5                                  
     C     LastMonth     Oreq      7                                  
     C     LastMonth     Oreq      8                                  
     C     LastMonth     Oreq      10                                 
     C     LastMonth     Oreq      12                                 
     C                   Z-add     31            DayNumber            
     C     LastMonth     WhenEq    4                                  
     C     LastMonth     Oreq      6                                  
     C     LastMonth     Oreq      9                                  
     C     LastMonth     Oreq      11                                 
     C                   Z-add     30            DayNumber            
     C                   EndSl      
</pre>
<p>This isn&#8217;t a perfect solution (if you can divide the year by 4, it&#8217;s not *always* a leap year), but it should work for most situations.</p>
<p>Regards,</p>
<p>Martin Gilbert.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teckgeck</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/determine-last-day-of-previous-month/#comment-54085</link>
		<dc:creator>teckgeck</dc:creator>
		<pubDate>Fri, 20 Jun 2008 15:44:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-54085</guid>
		<description><![CDATA[the answer is basically right - here is the RPG

as you can see - manuipulate the date in the data structure so that the current date is changed to the first of the current month - then subtract 1 day

DTODAY            DS                  
D TODAYD                          D   

 /FREE                                
   TODAYD = %DATE();                  
   %SUBST(TODAY:9:2) = &#039;01&#039;;          
   TODAYD-=%DAYS(1);                  
   *INLR = *ON;                       
 /END-FREE]]></description>
		<content:encoded><![CDATA[<p>the answer is basically right &#8211; here is the RPG</p>
<p>as you can see &#8211; manuipulate the date in the data structure so that the current date is changed to the first of the current month &#8211; then subtract 1 day</p>
<p>DTODAY            DS<br />
D TODAYD                          D   </p>
<p> /FREE<br />
   TODAYD = %DATE();<br />
   %SUBST(TODAY:9:2) = &#8217;01&#8242;;<br />
   TODAYD-=%DAYS(1);<br />
   *INLR = *ON;<br />
 /END-FREE</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/10 queries in 0.271 seconds using memcached
Object Caching 337/343 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-21 22:08:26 -->