One way to get the week number of a passed date is to use intrinsic functions.
Using several functions available in isCOBOL, you can get the Julian date, which will give you the date's number of days in the year.
Divide this by 7 and you'll have the week number.
For instance, December 25th is the 359th day of the year. The Julian date for December 25, 2023 is "2023225".
Using the fraction-part and integer-part functions, we can determine this is the 52nd week of the year
Compile and run the attached program with these commands:
iscc week-of-year.cbl iscrun WEEK_OF_YEARYour output will look like this for Christmas day, 2023:
For date 20231225, The julian value is 2023359, and that date is in week # 52 of the year.Other examples of using intrinsic functions to manipulate dates can be found in the sample programs installed in $ISCOBOL/sample/is-java/iscobol-uses-cobol-object/IS_DATE.
Article ID: 336
Created: February 17, 2023
Last Updated: February 17, 2023
Author: Support KB Author
Online URL: https://support.veryant.com/phpkb/article.php?id=336