Page 1 of 1

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

Posted: Wed Jan 25, 2017 5:14 pm
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.

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

Posted: Wed Jan 25, 2017 6:12 pm
by Robert Sample
There is no such function in Enterprise COBOL. It is not difficult to develop code for such a function, though.

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

Posted: Mon Feb 06, 2017 11:07 am
by alpna
Thanks Robert.

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

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

Posted: Mon Feb 06, 2017 6:28 pm
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).