## Adding the values of the table using [SEARCH STATEMENT]

Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

### Adding the values of the table using [SEARCH STATEMENT]

Hello guys! It's been a while that I am learning cobol .

Now, I need a little logic help. You see, I need to create a routine to add the values of DAYS depending on the input MONTH. I already got the idea of the Leap Year. Only the DAYS and MONTHS left.

Let's say I have a table that redefines my other variables '31283130313030313130313031' occurs 2, then the values of each number like, 31 will be added until 12 times is met.

or if there's a more efficient way to add the DAYS of the YEAR to an INPUT MONTH.

Let's say Feb 1 is equal to 32 days if it's not a leap year. Thanks!
Rayster

Posts: 8
Joined: Mon Dec 20, 2010 9:07 pm
Has thanked: 0 time
Been thanked: 0 time

### Re: Adding the values of the table using [SEARCH STATEMENT]

What is the problem you're trying to solve? Converting a date to integer using the INTEGER-OF-DATE FUNCTION, adding the right number of days, then converting back to a date using the DATE-OF-INTEGER FUNCTION is usually the best way to increment dates since you don't have to worry about the varying number of days per month.
Robert Sample
Global moderator

Posts: 3686
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 274 times

### Re: Adding the values of the table using [SEARCH STATEMENT]

Alright. I already figured it out again by myself. I use Perform varying from that table until it reaches the specified month given. No sense asking this question on Yahoo Answer as people will reply "Are you still living on the current time?" lol
Rayster

Posts: 8
Joined: Mon Dec 20, 2010 9:07 pm
Has thanked: 0 time
Been thanked: 0 time

### Re: Adding the values of the table using [SEARCH STATEMENT]

Hello,

Well, you've chosen a "solution" that will most often use more system resources and require more code be maintained than if you'd have used the method Robert suggested. . .

Alright. I already figured it out again by myself.
If you are going to prefer your learning-attempt solutions over experienced suggestions you might want to spend much more time on "your" solution and not be bothered by our suggestions that for whatever reason you prefer not to use. . .
Hope this helps,
d.sch.

dick scherrer
Global moderator

Posts: 6269
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

### Re: Adding the values of the table using [SEARCH STATEMENT]

^ Hello sir! I already noted the function as I am learning cobol. I'll try it next time as your suggestions helps me.
Rayster

Posts: 8
Joined: Mon Dec 20, 2010 9:07 pm
Has thanked: 0 time
Been thanked: 0 time