 




<?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: Date calculation question</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/</link>
	<description></description>
	<lastBuildDate>Wed, 22 May 2013 18:27:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: donethat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-76504</link>
		<dc:creator>donethat</dc:creator>
		<pubDate>Mon, 26 Apr 2010 22:25:25 +0000</pubDate>
		<guid isPermaLink="false">#comment-76504</guid>
		<description><![CDATA[OK BK...I must confess I&#039;m not great at reading/responding to forums.

Maybe Jlanus will read my inquiry. I would start a new thread but the history of the question is all tied up in this thread. Would be a heck of a convoluted post.

Til next time]]></description>
		<content:encoded><![CDATA[<p>OK BK&#8230;I must confess I&#8217;m not great at reading/responding to forums.</p>
<p>Maybe Jlanus will read my inquiry. I would start a new thread but the history of the question is all tied up in this thread. Would be a heck of a convoluted post.</p>
<p>Til next time</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bigkat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-76494</link>
		<dc:creator>bigkat</dc:creator>
		<pubDate>Mon, 26 Apr 2010 14:36:45 +0000</pubDate>
		<guid isPermaLink="false">#comment-76494</guid>
		<description><![CDATA[Hi DoneThat,
that was Jlanus syntax, (see my prev message - I just added the word &quot;day&quot; after the case &quot;end&quot;)  -- and I just ran the &quot;char ( current date ... end day, ISO)&quot; in a select from sysibm.sysdummy1like you did

Which was how I realized it needed the &quot;day&quot;

I really wasn&#039;t trying to steal the credit]]></description>
		<content:encoded><![CDATA[<p>Hi DoneThat,<br />
that was Jlanus syntax, (see my prev message &#8211; I just added the word &#8220;day&#8221; after the case &#8220;end&#8221;)  &#8212; and I just ran the &#8220;char ( current date &#8230; end day, ISO)&#8221; in a select from sysibm.sysdummy1like you did</p>
<p>Which was how I realized it needed the &#8220;day&#8221;</p>
<p>I really wasn&#8217;t trying to steal the credit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: donethat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-76419</link>
		<dc:creator>donethat</dc:creator>
		<pubDate>Fri, 23 Apr 2010 20:35:45 +0000</pubDate>
		<guid isPermaLink="false">#comment-76419</guid>
		<description><![CDATA[Hello BK. Maybe you can help me with something?
I wrote the following to make your SQL example work...

&lt;pre&gt;
WITH 	dummy AS (
SELECT 
	CHAR(
		CURRENT DATE +
			CASE 
				WHEN DAYOFWEEK(CURRENT DATE + 1 day) = 6 THEN 1
				WHEN DAYOFWEEK(CURRENT DATE + 2 day) = 6 THEN 2
				WHEN DAYOFWEEK(CURRENT DATE + 3 day) = 6 THEN 3
				WHEN DAYOFWEEK(CURRENT DATE + 4 day) = 6 THEN 4
				WHEN DAYOFWEEK(CURRENT DATE + 5 day) = 6 THEN 5
				WHEN DAYOFWEEK(CURRENT DATE + 6 day) = 6 THEN 6
				WHEN DAYOFWEEK(CURRENT DATE + 7 day) = 6 THEN 7
			END 	day,
		ISO)
 AS dateOfNextFriday 
FROM	sysibm.sysdummy1
) 
SELECT 
	SUBSTR(dateOfNextFriday, 6, 2)
	&#124;&#124; SUBSTR(dateOfNextFriday, 9, 2)
	&#124;&#124; SUBSTR(dateOfNextFriday, 1, 4)
	AS DateOfNextFridayMMDDYYYY
	FROM	dummy 
WITH	NC;
&lt;/pre&gt;

But YOU wrote as a CTE with a different syntax i.e. with t(dateOfNextFriday) etc.

I cannot make that work. Can you mod my example above using your syntax?]]></description>
		<content:encoded><![CDATA[<p>Hello BK. Maybe you can help me with something?<br />
I wrote the following to make your SQL example work&#8230;</p>
<pre>
WITH 	dummy AS (
SELECT 
	CHAR(
		CURRENT DATE +
			CASE 
				WHEN DAYOFWEEK(CURRENT DATE + 1 day) = 6 THEN 1
				WHEN DAYOFWEEK(CURRENT DATE + 2 day) = 6 THEN 2
				WHEN DAYOFWEEK(CURRENT DATE + 3 day) = 6 THEN 3
				WHEN DAYOFWEEK(CURRENT DATE + 4 day) = 6 THEN 4
				WHEN DAYOFWEEK(CURRENT DATE + 5 day) = 6 THEN 5
				WHEN DAYOFWEEK(CURRENT DATE + 6 day) = 6 THEN 6
				WHEN DAYOFWEEK(CURRENT DATE + 7 day) = 6 THEN 7
			END 	day,
		ISO)
 AS dateOfNextFriday 
FROM	sysibm.sysdummy1
) 
SELECT 
	SUBSTR(dateOfNextFriday, 6, 2)
	|| SUBSTR(dateOfNextFriday, 9, 2)
	|| SUBSTR(dateOfNextFriday, 1, 4)
	AS DateOfNextFridayMMDDYYYY
	FROM	dummy 
WITH	NC;
</pre>
<p>But YOU wrote as a CTE with a different syntax i.e. with t(dateOfNextFriday) etc.</p>
<p>I cannot make that work. Can you mod my example above using your syntax?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bigkat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-76344</link>
		<dc:creator>bigkat</dc:creator>
		<pubDate>Thu, 22 Apr 2010 13:51:43 +0000</pubDate>
		<guid isPermaLink="false">#comment-76344</guid>
		<description><![CDATA[I wish there was an option to update the answer, without it looking like I am claiming the &lt;i&gt;&lt;b&gt;WHOLE &lt;/b&gt;&lt;/i&gt;answer.  I added one word - day - after the case statement, and well, now it shows I wrote it :(]]></description>
		<content:encoded><![CDATA[<p>I wish there was an option to update the answer, without it looking like I am claiming the <i><b>WHOLE </b></i>answer.  I added one word &#8211; day &#8211; after the case statement, and well, now it shows I wrote it <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-76328</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Thu, 22 Apr 2010 06:43:23 +0000</pubDate>
		<guid isPermaLink="false">#comment-76328</guid>
		<description><![CDATA[&lt;i&gt;Now I think I have heard that in ILE you can embed SQL statements...&lt;/i&gt;

You can indeed, as you also can with &quot;Old&quot; RPG. However...

You need to have the SQL compiler option to do that. I see that you&#039;re using an &quot;EXECUTE&quot; command to run SQL in a CL program. That suggests that you don&#039;t have clean access to QM, so you probably don&#039;t have the SQL compiler option. (They come in one product.)

It doesn&#039;t matter much if your programs are &quot;Old&quot; RPG or newer ILE. What matters most is the version of the operating system. If it&#039;s been kept up and you can still compile your old programs, then you can also compile ILE versions. All of the compilers are in a single package (until the very latest releases in 2010.)

Tom]]></description>
		<content:encoded><![CDATA[<p><i>Now I think I have heard that in ILE you can embed SQL statements&#8230;</i></p>
<p>You can indeed, as you also can with &#8220;Old&#8221; RPG. However&#8230;</p>
<p>You need to have the SQL compiler option to do that. I see that you&#8217;re using an &#8220;EXECUTE&#8221; command to run SQL in a CL program. That suggests that you don&#8217;t have clean access to QM, so you probably don&#8217;t have the SQL compiler option. (They come in one product.)</p>
<p>It doesn&#8217;t matter much if your programs are &#8220;Old&#8221; RPG or newer ILE. What matters most is the version of the operating system. If it&#8217;s been kept up and you can still compile your old programs, then you can also compile ILE versions. All of the compilers are in a single package (until the very latest releases in 2010.)</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: takeoption3please</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-53914</link>
		<dc:creator>takeoption3please</dc:creator>
		<pubDate>Fri, 13 Jun 2008 15:04:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-53914</guid>
		<description><![CDATA[Sorry, the previous all came out as a link, but I&#039;m new to this forum.
- jdl]]></description>
		<content:encoded><![CDATA[<p>Sorry, the previous all came out as a link, but I&#8217;m new to this forum.<br />
- jdl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: takeoption3please</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-53913</link>
		<dc:creator>takeoption3please</dc:creator>
		<pubDate>Fri, 13 Jun 2008 15:03:16 +0000</pubDate>
		<guid isPermaLink="false">#comment-53913</guid>
		<description><![CDATA[Hi Tom

I found the old routines I think you are looking for in the Midrange archives:

&lt;a href=&quot;http://archive.midrange.com/rpg400-l/199910/msg00340.html&quot;&gt;

One converts Julian to Gregorian and the other is reverse.  BTW, you can also use both routines to validate a date in &quot;old&quot; RPG.

Here is the text of the link:

I don&#039;t think it aligns properly here in this text box -

GTOJR1 (RPG)

C           *ENTRY    PLIST
C                     PARM           G$MM    20
C                     PARM           G$DD    20
C                     PARM           G$YYYY  40
C                     PARM           G$JD    50
C*
C                     Z-ADD0         G$JD
C           G$MM      SUB  3         G$MMWK  20
C                     Z-ADDG$MMWK    GMWKSV  20
C           G$MMWK    IFLT 0                           LVL-01
C                     ADD  12        G$MMWK
C                     END                              END-01
C           GMWKSV    IFNE 0                           LVL-01
C           G$MMWK    MULT 30.6      G$JD      H
C                     END                              END-01
C                     ADD  G$DD      G$JD    50
C           G$YYYY    SUB  1900      G$YYWK  30
C           G$YYWK    IFNE 0                           LVL-01
C           GMWKSV    IFLT 0                           LVL-02
C                     SUB  1         G$YYWK
C                     END                              END-02
C                     END                              END-01
C           G$YYWK    MULT 365.25    G$JYD   70
C                     ADD  G$JYD     G$JD
C           G$JD      DIV  7         G$WK7   70
C                     MVR            G$DW    10        0=Wed-6=Tue
C                     RETRN

JTOGR1 (RPG)

C           *ENTRY    PLIST
C                     PARM           J$JD    50
C                     PARM           J$MM    20
C                     PARM           J$DD    20
C                     PARM           J$YYYY  40
C*
C           J$JD      DIV  365.25    J$YYWK  30
C           J$JD      DIV  365.25    J$TST   99
C           J$TST     IFEQ 0                           LVL-01
C                     SUB  1         J$YYWK
C                     END                              END-01
C           J$YYWK    MULT 365.25    J$YD    70
C           J$JD      SUB  J$YD      J$YD
C           J$YD      IFGT 306                         LVL-01
C                     ADD  1         J$YYWK
C                     END                              END-01
C                     Z-ADD0         J$X     20
C           J$YD      DOULEJ$MD                        LVL-01
C                     ADD  1         J$X
C           J$X       MULT 30.6      J$MD    30H
C                     END                              END-01
C                     SUB  1         J$X
C           J$X       MULT 30.6      J$MD      H
C           J$YD      SUB  J$MD      J$DD    20
C           J$X       ADD  3         J$MM    20
C           J$MM      IFGT 12                          LVL-01
C                     SUB  12        J$MM
C                     END                              END-01
C           J$YYWK    ADD  1900      J$YYYY  40
C                     SETON                     LR
C                     RETRN

Hope this helps]]></description>
		<content:encoded><![CDATA[<p>Hi Tom</p>
<p>I found the old routines I think you are looking for in the Midrange archives:</p>
<p><a href="http://archive.midrange.com/rpg400-l/199910/msg00340.html"></p>
<p>One converts Julian to Gregorian and the other is reverse.  BTW, you can also use both routines to validate a date in &#8220;old&#8221; RPG.</p>
<p>Here is the text of the link:</p>
<p>I don&#8217;t think it aligns properly here in this text box -</p>
<p>GTOJR1 (RPG)</p>
<p>C           *ENTRY    PLIST<br />
C                     PARM           G$MM    20<br />
C                     PARM           G$DD    20<br />
C                     PARM           G$YYYY  40<br />
C                     PARM           G$JD    50<br />
C*<br />
C                     Z-ADD0         G$JD<br />
C           G$MM      SUB  3         G$MMWK  20<br />
C                     Z-ADDG$MMWK    GMWKSV  20<br />
C           G$MMWK    IFLT 0                           LVL-01<br />
C                     ADD  12        G$MMWK<br />
C                     END                              END-01<br />
C           GMWKSV    IFNE 0                           LVL-01<br />
C           G$MMWK    MULT 30.6      G$JD      H<br />
C                     END                              END-01<br />
C                     ADD  G$DD      G$JD    50<br />
C           G$YYYY    SUB  1900      G$YYWK  30<br />
C           G$YYWK    IFNE 0                           LVL-01<br />
C           GMWKSV    IFLT 0                           LVL-02<br />
C                     SUB  1         G$YYWK<br />
C                     END                              END-02<br />
C                     END                              END-01<br />
C           G$YYWK    MULT 365.25    G$JYD   70<br />
C                     ADD  G$JYD     G$JD<br />
C           G$JD      DIV  7         G$WK7   70<br />
C                     MVR            G$DW    10        0=Wed-6=Tue<br />
C                     RETRN</p>
<p>JTOGR1 (RPG)</p>
<p>C           *ENTRY    PLIST<br />
C                     PARM           J$JD    50<br />
C                     PARM           J$MM    20<br />
C                     PARM           J$DD    20<br />
C                     PARM           J$YYYY  40<br />
C*<br />
C           J$JD      DIV  365.25    J$YYWK  30<br />
C           J$JD      DIV  365.25    J$TST   99<br />
C           J$TST     IFEQ 0                           LVL-01<br />
C                     SUB  1         J$YYWK<br />
C                     END                              END-01<br />
C           J$YYWK    MULT 365.25    J$YD    70<br />
C           J$JD      SUB  J$YD      J$YD<br />
C           J$YD      IFGT 306                         LVL-01<br />
C                     ADD  1         J$YYWK<br />
C                     END                              END-01<br />
C                     Z-ADD0         J$X     20<br />
C           J$YD      DOULEJ$MD                        LVL-01<br />
C                     ADD  1         J$X<br />
C           J$X       MULT 30.6      J$MD    30H<br />
C                     END                              END-01<br />
C                     SUB  1         J$X<br />
C           J$X       MULT 30.6      J$MD      H<br />
C           J$YD      SUB  J$MD      J$DD    20<br />
C           J$X       ADD  3         J$MM    20<br />
C           J$MM      IFGT 12                          LVL-01<br />
C                     SUB  12        J$MM<br />
C                     END                              END-01<br />
C           J$YYWK    ADD  1900      J$YYYY  40<br />
C                     SETON                     LR<br />
C                     RETRN</p>
<p>Hope this helps</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gilly400</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-53910</link>
		<dc:creator>gilly400</dc:creator>
		<pubDate>Fri, 13 Jun 2008 14:48:31 +0000</pubDate>
		<guid isPermaLink="false">#comment-53910</guid>
		<description><![CDATA[Hi TomN,

You can embed SQL in &quot;normal&quot; RPG/400 as well as ILE.  You&#039;ll need to make the source type SQLRPG for RPG/400 or SQLRPGLE for ILE RPG, then SEU will error check the embedded SQL for you and you can compile using option 14 from PDM.

Regards,

Martin Gilbert.]]></description>
		<content:encoded><![CDATA[<p>Hi TomN,</p>
<p>You can embed SQL in &#8220;normal&#8221; RPG/400 as well as ILE.  You&#8217;ll need to make the source type SQLRPG for RPG/400 or SQLRPGLE for ILE RPG, then SEU will error check the embedded SQL for you and you can compile using option 14 from PDM.</p>
<p>Regards,</p>
<p>Martin Gilbert.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomn</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-53900</link>
		<dc:creator>tomn</dc:creator>
		<pubDate>Thu, 12 Jun 2008 21:36:59 +0000</pubDate>
		<guid isPermaLink="false">#comment-53900</guid>
		<description><![CDATA[Thanks for all your replies...  I am sad to tell you that I have not had any exposure to RPGLE first hand.  We have some old apps that I have needed to do small updates to over the years but all our programs are &quot;older style&quot; RPG II code that was brought forward by our software company back in &#039;98 with very little change to the code and we were supplied the source code to do some customizations to if we needed to, although it was frowned upon.  Most of our &quot;custom&quot; reports have been created by us using the Sequel product from HelpSystems, which has performed beautifully for us these last 9 years or so.  We have been in the process of upgrading to our software company’s newer versions and I am seeing more and more ILE in their libraries.  The thing I am trying to work with is one of our older apps and have been looking for a way to do this in the &quot;old&quot; code structure (that I am used to).  I have just built something using SQL and a short little RPG program that I think will do the trick.  I pass the output to a temp file and then read it using the little RPG program and place the date in the needed LDA positions for the final program to grab.  

One line of script:  EXECUTE SQL(&#039;select &quot;&amp;&amp;Adate&quot; name(ldavalA) from sequelu/sqlexec&#039;) OUTFILE(QTEMP/QQ) REPLACE(*YES) 

With a variable defined like this:   SQL(MMDDYY(current date+(6-dayofweek(current date))days))

Then read the file and put the data where needed:
H                                                                    FRILDA 
H*... Reads date in temp file and puts in LDA positions desired            
FQQ      IP  F      10            DISK                                      
IQQ      NS  01                                                             
I                                        1   60FRIDA                        
I           UDS                                                             
I                                      151 1560FRIDA                        

Now I think I have heard that in ILE you can embed SQL statements, if this is true, could that SQL be placed right in the RPG and do it in one step?  This is working for me now but am interested in looking further into “newer style” code.  

All this is just to reduce repetitious operator input and reduce errors!]]></description>
		<content:encoded><![CDATA[<p>Thanks for all your replies&#8230;  I am sad to tell you that I have not had any exposure to RPGLE first hand.  We have some old apps that I have needed to do small updates to over the years but all our programs are &#8220;older style&#8221; RPG II code that was brought forward by our software company back in &#8217;98 with very little change to the code and we were supplied the source code to do some customizations to if we needed to, although it was frowned upon.  Most of our &#8220;custom&#8221; reports have been created by us using the Sequel product from HelpSystems, which has performed beautifully for us these last 9 years or so.  We have been in the process of upgrading to our software company’s newer versions and I am seeing more and more ILE in their libraries.  The thing I am trying to work with is one of our older apps and have been looking for a way to do this in the &#8220;old&#8221; code structure (that I am used to).  I have just built something using SQL and a short little RPG program that I think will do the trick.  I pass the output to a temp file and then read it using the little RPG program and place the date in the needed LDA positions for the final program to grab.  </p>
<p>One line of script:  EXECUTE SQL(&#8216;select &#8220;&amp;&amp;Adate&#8221; name(ldavalA) from sequelu/sqlexec&#8217;) OUTFILE(QTEMP/QQ) REPLACE(*YES) </p>
<p>With a variable defined like this:   SQL(MMDDYY(current date+(6-dayofweek(current date))days))</p>
<p>Then read the file and put the data where needed:<br />
H                                                                    FRILDA<br />
H*&#8230; Reads date in temp file and puts in LDA positions desired<br />
FQQ      IP  F      10            DISK<br />
IQQ      NS  01<br />
I                                        1   60FRIDA<br />
I           UDS<br />
I                                      151 1560FRIDA                        </p>
<p>Now I think I have heard that in ILE you can embed SQL statements, if this is true, could that SQL be placed right in the RPG and do it in one step?  This is working for me now but am interested in looking further into “newer style” code.  </p>
<p>All this is just to reduce repetitious operator input and reduce errors!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bigkat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/date-calculation-question/#comment-53874</link>
		<dc:creator>bigkat</dc:creator>
		<pubDate>Wed, 11 Jun 2008 16:04:57 +0000</pubDate>
		<guid isPermaLink="false">#comment-53874</guid>
		<description><![CDATA[Unless there is a typo I am not seeing, my free format RPG(LE) code should have worked unless you are on an older O/S level???

Kevin]]></description>
		<content:encoded><![CDATA[<p>Unless there is a typo I am not seeing, my free format RPG(LE) code should have worked unless you are on an older O/S level???</p>
<p>Kevin</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 6/9 queries in 0.013 seconds using memcached
Object Caching 398/401 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-23 00:06:02 -->