165 pts.
 Days of the week in AS/400 V5R4
I know how to determine the day of the week a date falls on. However, I was wondering if there was an easy way to figure the following information: 02/01/10 was the 5th Monday of year 2010, 01/07/11 is the 1st Friday of 2011, etc.?

Software/Hardware used:
as400 v5r4
ASKED: January 4, 2011  5:08 PM
UPDATED: January 4, 2011  7:57 PM

Answer Wiki:
Are you asking for a routine to deterime the n occurnace of a day of the year. 4th Sat, 21st Mon, 17 Tues, ... ? If so, determine day of week for Jan 1st of the requester year. If day of week does not equal the day of week your looking for (1st is a Tues an you are looking for Fri), add x days to this date. where x is the differential. In the above case it would be 3 (Wed, Thur, Fri). Now multiple n * 7 and add that number of days to your result date from above. That would give you what you want.
Last Wiki Answer Submitted:  January 4, 2011  7:12 pm  by  CharlieBrowne   33,595 pts.
All Answer Wiki Contributors:  CharlieBrowne   33,595 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I have a program in which I need to compare let’s say the 5th Monday of 2011 to the 5th Monday of 2010. As a result, I need the program to tell me what date in 2010 is the 5th Monday.

 165 pts.

 

I don’t have such a routine handy, but you might try running a statement like this and studying the result:

SELECT week(current date),
       week(current date - 1 days),
       week(current date - 3 days),
       week(current date - 8 days),
       week(current date + 8 days) FROM sysibm/sysdummy1

The WEEK() and WEEK_ISO() functions might be of use in doing such date manipulation. Read the SQL documentation on the functions and make sure that you understand what the definition of a “week number” is. You’ll want to be sure that your company’s use of a “week number” matches with standards.

Tom

 109,995 pts.