If you know how to define a table in cobol and you know the rule "Thirty days hath Sept..." and you know month 1 is JAN, month 2 is Feb, etc., you should be able to solve your problem. Was this a big enough hint?
Hi Hugh,
If you fancy learning a few of the slightly more unusual functions that Cobol has, you could use the DATE-OF-INTEGER and INTEGER-OF-DATE functions to achieve this. Let's suppose that you want to know the last date of the last day in February next year. You could:
a)Set a field with the value 01-03-2003
b)Use the INTEGER-OF-DATE function to give you a number, and then subtract 1 from that number.
c)Use the DATE-OF-INTEGER function to get you back the last day in February.
OK, I'll admit that this is a little on the esoteric side, but it will work, and will give you an insight into some of the less used features in Cobol.
The FUNCTION method for finding the # of days in a month (i.e., the last day of the month) is ok for 1 or 2 or a handful of dates. If you plan to use it for each date in a record of an IP file, the performance hit may argue against it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.