Question ID : 336
Created on 2023-02-17 at 7:45 AM
Author : Veryant Support [email@example.com]
Online URL : http://support.veryant.com/support/phpkb/question.php?ID=336
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.
Back to Original Question