Page 1 of 1

Adding the values of the table using [SEARCH STATEMENT]

PostPosted: Sat Jan 08, 2011 10:10 pm
by Rayster
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!

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

PostPosted: Sat Jan 08, 2011 10:18 pm
by Robert Sample
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.

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

PostPosted: Sun Jan 09, 2011 9:26 pm
by Rayster
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 :D

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

PostPosted: Sun Jan 09, 2011 10:37 pm
by dick scherrer
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. . .

Your "subject" mentions SEARCH, but your last post mentions "perform varying".

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. . .

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

PostPosted: Tue Jan 11, 2011 8:42 pm
by Rayster
^ Hello sir! I already noted the function as I am learning cobol. I'll try it next time as your suggestions helps me. :)