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

All sort of Mainframes Interview Questions.
Post Reply
alpna
Registered Member
Posts: 56
Joined: Fri Jun 21, 2013 10:35 pm

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

Post by alpna »

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: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post by Robert Sample »

There is no such function in Enterprise COBOL. It is not difficult to develop code for such a function, though.
alpna
Registered Member
Posts: 56
Joined: Fri Jun 21, 2013 10:35 pm

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

Post by alpna »

Thanks Robert.

Could you please help me to layout a logic for it in COBOL?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1895
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

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

Post by Robert Sample »

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).
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 “Interview Questions.”