Intrinsic function of COBOL to identify a specific day of the month?

All sort of Mainframes Interview Questions.
Previous topicNext topic

Topic Author
alpna
Registered Member
Posts: 36
Joined: Fri Jun 21, 2013 10:35 pm
Zodiac: Virgo

Intrinsic function of COBOL to identify a specific day of the month?

Post by alpna » Wed Jan 25, 2017 5:14 pm

Hi,

Do we have some intrinsic function of COBOL to identify a specific day of the month? For example to check if the given date is second Monday of the month?

I did not answer this question. I thought there was a function but I cold not find one later online.



User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1328
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: Intrinsic function of COBOL to identify a specific day of the month?

Post by Robert Sample » Wed Jan 25, 2017 6:12 pm

There is no such function in Enterprise COBOL. It is not difficult to develop code for such a function, though.




Topic Author
alpna
Registered Member
Posts: 36
Joined: Fri Jun 21, 2013 10:35 pm
Zodiac: Virgo

Re: Intrinsic function of COBOL to identify a specific day of the month?

Post by alpna » Mon Feb 06, 2017 11:07 am

Thanks Robert.

Could you please help me to layout a logic for it in COBOL?



User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1328
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
Zodiac: Virgo

Re: Intrinsic function of COBOL to identify a specific day of the month?

Post by Robert Sample » Mon Feb 06, 2017 6:28 pm

Pick a known date and convert it to integer using the INTEGER-OF-DATE intrinsic function. Convert your date to integer and find the difference in the dates. If the difference modulo 7 is zero then your date is the same day of week as your known date; otherwise, you can determine the day of week by the modulus. As far as finding the second Monday, for example, one way would be to convert the 8th day of the month to integer and using the difference from your known date to adjust to Monday (the second Monday will not be earlier than the 8th nor later than the 14th).



Previous topicNext topic

Return to “Interview Questions.”