View previous topic :: View next topic
|
Author |
Message |
sreenigacc
New User
Joined: 16 Oct 2007 Posts: 15 Location: bangalore
|
|
|
|
Hi,
some one can help me out.......
the problem is
05 WS-INPUDATE PIC 9(08) VALUE ZEROS.
COMPUTE WS-DAY = FUNCTION MOD (FUNCTION
INTEGER-OF-DATE (WS-INPUDATE)7).
could you pls explain this how it works exactly....... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
integer_of_date returns an integer which has the peculiarity that
the remainder of the division by 7 ( modulus function )
gives the number of the day of the week 0-subday .... 6-saturday |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
also need to populate WS-INPUDATE with a valid date. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi,
What's the purpose of the "7" in your COMPUTE stmt? |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
mmwife wrote: |
Hi,
What's the purpose of the "7" in your COMPUTE stmt? |
Quote: |
the remainder of the division by 7 ( modulus function )
|
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You can eliminate the MOD FUNCTION by doing -
Code: |
03 WS-INTEGER-OF-DATE PIC S9(09) COMP-3.
03 WS-REMAINDER PIC S9(03) COMP-3.
03 WS-JUNK PIC S9(09) COMP-3.
03 WS-DATE PIC 9(08) VALUE 20080325.
COMPUTE WS-INTEGER-OF-DATE = FUNCTION INTEGER-OF-DATE(WS-DATE).
DIVIDE WS-INTEGER-OF-DATE BY 7 GIVING WS-JUNK
REMAINDER WS-REMAINDER.
IF WS-REMAINDER = ZERO
MOVE 7 TO WS-REMAINDER
END-IF.
|
At this point, the value in WS-REMAINDER will be in the range of 1 through 7 (Monday through Sunday). In this example, it will equal 2.
HTH....
Regards,
Bill |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
If you divide by 7 the remainder must be in the range of 0 through 6! |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Code: |
IF WS-REMAINDER = ZERO
MOVE 7 TO WS-REMAINDER
END-IF. |
Quote: |
f you divide by 7 the remainder must be in the range of 0 through 6! |
fast fingers or fat eyes |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Quote: |
If you divide by 7 the remainder must be in the range of 0 through 6! |
What Bill meant was that AFTER the IF stmt WS-REMAINDER will contain 1 thru 7 (Mon thru Sun). |
|
Back to top |
|
|
|