RPGPGM.COM - From AS400 to IBM i › Calculating end of month part II
After publishing the post Calculating end of month on how I would do it in RPG/free, yesterday, I received a number of messages on how the same can be achieved in SQL.
I want to thank everyone who sent me a message, I really do appreciate the feedback.
Having tried every snippet I was sent I did find one that I appreciate its simplicity.
The source code below, is based upon the examples sent by John Joiner, David Ford, and Robert Rogerson, who suggested the SQL function LAST_DAY:
01 D wkDate S D
The LAST_DATE function determines the last day of the month for the expression it is given. In this example the expression is the current date, which is the SQL function CURRENT_DATE. I take the value from the LAST_DATE and move it to a date data type field, wkDate, that can be used in the rest of the program.
I have stored this away in my own examples file to use in the future.
You can learn more about the LAST_DAY function on the IBM website here»
This article was written for OS i 7.1, and it should work with earlier releases too.
Read the original at RPGPGM.COM - From AS400 to IBM i.