Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 8500

COBOL Programming :: RE: How to find the first monday of the week.

$
0
0
Author: Robert Sample
Posted: Fri Nov 25, 2016 9:54 pm (GMT 5.5)

COBOL does not have great date processing functions, so there is no routine to do what you want. You will need to write one yourself. And since you provided almost nothing about what you need in your post, the routine will have to be written by you.

Questions you did not answer in your post include:
- Will the week number always be for this year?
- How is the week number determined -- from Sunday? from Monday? from some other day?
- What happens when the year changes during the week (for example, in 2019 the first of January is on a Tuesday)?
- What if the week number comes in as something greater than 53?

Once you have a complete determination of the requirements, writing a routine is pretty easy -- convert the date for the Monday of week 1 to integer using the intrinsic function, add 7 times the week number to that value, then convert back to a date using the intrinsic function. That assumes you're only dealing with week numbers for a single year, of course.
_________________
TANSTAAFL

The first rule of code reuse is that the code needs to be worth re-using.

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth


Viewing all articles
Browse latest Browse all 8500

Trending Articles