Need to add hours from given time



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

Need to add hours from given time

Postby deva_048 » Tue Jun 11, 2013 8:58 pm

While using the function getting error shown below:

DISPLAY FUNCTION ADD-DURATION (WS-TIME MINUTES 15)

EXPECTED A FUNCTION-NAME, BUT FOUND "ADD-DURATION". THE "DISPLAY" STATEMENT WAS DISCARDED.

Version: IBM ENTERPRISE COBOL FOR Z/OS 4.2.0 0
deva_048
 
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Need to add hours from given time

Postby Robert Sample » Tue Jun 11, 2013 9:18 pm

When I look at the Enterprise COBOL 4.2 Language Refernce manual, there is no ADD-DURATION function listed in the manuall -- neither in the intrinsic function list, nor in the Index. So where did you get the idea that such a function exists in COBOL?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need to add hours from given time

Postby deva_048 » Tue Jun 11, 2013 9:20 pm

While browsing in net i have found out this idea everyone mentioned... Is there any other possible way to implement this??
deva_048
 
Posts: 72
Joined: Thu Feb 02, 2012 9:28 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Need to add hours from given time

Postby Robert Sample » Tue Jun 11, 2013 9:25 pm

You have, hopefully learned the first lesson about browsing the Internet for information -- not everything you read on the Internet is accurate and true.

If you are wanting to add hours to a given time, there are two verbs in COBOL that can do this: ADD and COMPUTE. Which you use will depend upon your level of COBOL expertise. You will also have to consider what your time value represents -- elapsed time or time of day. The different is 37 hours is a perfectly valid elapsed time value, whereas time of day values will be limited to the range 0 to 12 (or 0 to 24). For time of day values, if you go over the maximum you need to determine what to do (add 1 to a day field, or just subtract the maximum value from the computation, or something else).
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need to add hours from given time

Postby Akatsukami » Tue Jun 11, 2013 10:12 pm

When you saw that there were real answers in this thread, Deva-kun, what did you do?
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Need to add hours from given time

Postby dick scherrer » Tue Jun 11, 2013 11:38 pm

Hello,

While browsing in net i have found out this idea everyone mentioned...

No, NOT everyone has mentioned this . . . And if some did, did you ensure they are using the IBM compiler on the mainframe?

Is here some particular reason you chose to ask the same question as your other post that Akatsukaimi referenced?

Just because you let a couple of weeks go by, do not expect different answers. You were given ways to get to your goal.

It is good to look for things on your own - we highly encourage this, but is is not so good to ask about syntax you have not even verified in the COBOL manual.

Good luck :)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post