How to validate month end is Saturday in COBOL?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Rohit Datta
New Member
Posts: 9
Joined: Wed Apr 23, 2014 10:04 pm

How to validate month end is Saturday in COBOL?

Post by Rohit Datta »

Hi,

I need to validate if the month end is Saturday or not using COBOL, if month end is Saturday, I'd want to display invalid date else valid date. My inputs will be something like:

Input

Code: Select all

20140430 
20140531 
20140630 
Output

Code: Select all

20140430 valid date 
20140531 invalid date 
20140630 valid date 
How can I achieve this?
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: How to validate month end is Saturday in COBOL?

Post by William Collins »

Have a look at what intrinsic FUNCTIONs are available.
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to validate month end is Saturday in COBOL?

Post by Anuj Dhawan »

Hi,

Try this:

Code: Select all

01 WS-IN-DATE           PIC 9(8).                  
01 WS-ANS               PIC S9(08) COMP.            
01 WS-INT               PIC S9(08) COMP.            
01 WS-REMAINDER         PIC S9(04) COMP. 

COMPUTE WS-INT = FUNCTION INTEGER-OF-DATE(WS-IN-DATE) 
                                                          
DIVIDE WS-INT  BY 7 GIVING    WS-ANS
                    REMAINDER WS-REMAINDER            
                                                          
ADD 1 TO WS-REMAINDER                                      
                                                          
IF WS-REMAINDER = 7                                        
   DISPLAY 'INVALID DATE : ' WS-IN-DATE                  
ELSE                                                      
   DISPLAY 'VALID DATE   : ' WS-IN-DATE                  
END-IF
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Rohit Datta
New Member
Posts: 9
Joined: Wed Apr 23, 2014 10:04 pm

Re: How to validate month end is Saturday in COBOL?

Post by Rohit Datta »

Thanksfor the help Anuj! Long live! :)
User avatar
Anuj Dhawan
Founder
Posts: 2802
Joined: Sun Apr 21, 2013 7:40 pm
Location: Mumbai, India
Contact:
India

Re: How to validate month end is Saturday in COBOL?

Post by Anuj Dhawan »

The Signature wrote:The problem is, you think you have time. - Budha
Rohit Datta wrote:Long live! :)
Great! :D
Thanks,
Anuj

Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”