IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Explanation about Day-of-week in cobol?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sreenigacc

New User


Joined: 16 Oct 2007
Posts: 15
Location: bangalore

PostPosted: Tue Mar 25, 2008 5:58 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Mar 25, 2008 6:01 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 25, 2008 6:07 pm
Reply with quote

also need to populate WS-INPUDATE with a valid date.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Mar 25, 2008 6:35 pm
Reply with quote

Hi,

What's the purpose of the "7" in your COMPUTE stmt?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 25, 2008 6:47 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 25, 2008 6:57 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Mar 25, 2008 7:03 pm
Reply with quote

If you divide by 7 the remainder must be in the range of 0 through 6!
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Mar 25, 2008 7:07 pm
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Mar 25, 2008 8:38 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top