|
|
| Dennis Dahn 2007-03-02, 7:55 am |
| Hello,
I want to save the time that is needed for some action in the format
hh:mm:ss.
So I defined the variable as below.
01 TimeVars.
05 TimeStart.
10 CurrentHour PIC 99.
10 CurrentMinute PIC 99.
10 CurrentSecond PIC 99.
10 FILLER PIC 9(4).
05 TimeEnd PIC 99.
10 CurrentHour PIC 99.
10 CurrentMinute PIC 99.
10 CurrentSecond PIC 99.
10 FILLER PIC 9(4).
05 TimeTotal.
10 CurrentHour PIC 99.
10 CurrentMinute PIC 99.
10 CurrentSecond PIC 99.
10 FILLER PIC 9(4).
To save the time I tried this:
ACCEPT TimeStart From Time.
* later...
ACCEPT TimeEnd FROM TIME
SUBTRACT timestart FROM timeend into timetoal
DISPLAY timetotal.
But then I get the errorsmessage:
'timestart' may not be alphanumeric.
How can I do this?
Thanks a lot for your help!
Regards,
Dennis
| |
| Jack Klappe 2007-03-02, 7:55 am |
| You need some extra numeric variables let we say: TimeStart-N and TimeEnd-N
and TimeDifference-N
And next calculate: TimeStart-N = CurrentHour in TimeStart + 60 *
CurrentMinute in TimeStart + 3600 * CurrentSecond in TimeStart
Also: TimeEnd-N = CurrentHour in TimeEnd + 60 * CurrentMinute in TimeEnd +
3600 * CurrentSecond in TimeEnd
Next: Calculate the TimeDifference-N (in seconds) and recalculate and
rebuild it in the format hh:mm:ss
I think I did a great part of your homework ;-))
Good luck,
Jack
"Dennis Dahn" <DDahn@web.de> schreef in bericht
news:45e80166$0$15953$9b4e6d93@newsspool
4.arcor-online.net...
> Hello,
>
> I want to save the time that is needed for some action in the format
> hh:mm:ss.
> So I defined the variable as below.
>
> 01 TimeVars.
> 05 TimeStart.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeEnd PIC 99.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeTotal.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
>
>
> To save the time I tried this:
>
> ACCEPT TimeStart From Time.
>
> * later...
>
> ACCEPT TimeEnd FROM TIME
> SUBTRACT timestart FROM timeend into timetoal
> DISPLAY timetotal.
>
> But then I get the errorsmessage:
> 'timestart' may not be alphanumeric.
>
> How can I do this?
> Thanks a lot for your help!
>
> Regards,
>
> Dennis
>
| |
| Jack Klappe 2007-03-02, 7:55 am |
| Sorry,
You need some extra numeric variables let we say: TimeStart-N and TimeEnd-N
and TimeDifference-N
And next calculate: TimeStart-N = 3600 * CurrentHour in TimeStart + 60 *
CurrentMinute in TimeStart + CurrentSecond in TimeStart
Also: TimeEnd-N = 3600 * CurrentHour in TimeEnd + 60 * CurrentMinute in
TimeEnd + CurrentSecond in TimeEnd
Next: Calculate the TimeDifference-N (in seconds) and recalculate and
rebuild it in the format hh:mm:ss
I think I did a great part of your homework ;-))
Good luck,
Jack
"Jack Klappe" <jack.klappe@home.nl> schreef in bericht
news:es93ui$4er$1@news5.zwoll1.ov.home.nl...
> You need some extra numeric variables let we say: TimeStart-N and
> TimeEnd-N
> and TimeDifference-N
>
> And next calculate: TimeStart-N = CurrentHour in TimeStart + 60 *
> CurrentMinute in TimeStart + 3600 * CurrentSecond in TimeStart
> Also: TimeEnd-N = CurrentHour in TimeEnd + 60 * CurrentMinute in TimeEnd +
> 3600 * CurrentSecond in TimeEnd
>
> Next: Calculate the TimeDifference-N (in seconds) and recalculate and
> rebuild it in the format hh:mm:ss
>
> I think I did a great part of your homework ;-))
>
> Good luck,
>
> Jack
>
>
>
> "Dennis Dahn" <DDahn@web.de> schreef in bericht
> news:45e80166$0$15953$9b4e6d93@newsspool
4.arcor-online.net...
>
>
| |
| HeyBub 2007-03-02, 6:55 pm |
| Dennis Dahn wrote:
> Hello,
>
> I want to save the time that is needed for some action in the format
> hh:mm:ss.
> So I defined the variable as below.
>
> 01 TimeVars.
> 05 TimeStart.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeEnd PIC 99.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeTotal.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
>
>
> To save the time I tried this:
>
> ACCEPT TimeStart From Time.
>
> * later...
>
> ACCEPT TimeEnd FROM TIME
> SUBTRACT timestart FROM timeend into timetoal
> DISPLAY timetotal.
>
> But then I get the errorsmessage:
> 'timestart' may not be alphanumeric.
>
> How can I do this?
> Thanks a lot for your help!
Group items are alphanumeric and cannot be reliably used in an arithmetic
operation. Consider:
SUBTRACT author FROM city GIVING brand-name.
| |
| William M. Klein 2007-03-02, 6:55 pm |
| Others have told you:
A) Group items are alphanumeric rather than numeric
B) You need to do some calculations - as 11:35:49 - 10:46:52 will NOT give you
what you want (and if you think about your starting time being just before
midnight and the end time being after midnight, things get even worse)
***
However, no one has asked what compiler and operating system you are working
with. Many systems have "callable service" that let you get time in "seconds
since some specific start date/time". If you can get that, then calculating
"elapsed time" will be much easier.
--
Bill Klein
wmklein <at> ix.netcom.com
"Dennis Dahn" <DDahn@web.de> wrote in message
news:45e80166$0$15953$9b4e6d93@newsspool
4.arcor-online.net...
> Hello,
>
> I want to save the time that is needed for some action in the format hh:mm:ss.
> So I defined the variable as below.
>
> 01 TimeVars.
> 05 TimeStart.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeEnd PIC 99.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeTotal.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
>
>
> To save the time I tried this:
>
> ACCEPT TimeStart From Time.
>
> * later...
>
> ACCEPT TimeEnd FROM TIME
> SUBTRACT timestart FROM timeend into timetoal
> DISPLAY timetotal.
>
> But then I get the errorsmessage:
> 'timestart' may not be alphanumeric.
>
> How can I do this?
> Thanks a lot for your help!
>
> Regards,
>
> Dennis
>
| |
| John Simpson 2007-03-02, 6:55 pm |
|
"Dennis Dahn" <DDahn@web.de> wrote in message
news:45e80166$0$15953$9b4e6d93@newsspool
4.arcor-online.net...
> Hello,
>
> I want to save the time that is needed for some action in the format
> hh:mm:ss.
> So I defined the variable as below.
>
> 01 TimeVars.
> 05 TimeStart.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeEnd PIC 99.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
> 05 TimeTotal.
> 10 CurrentHour PIC 99.
> 10 CurrentMinute PIC 99.
> 10 CurrentSecond PIC 99.
> 10 FILLER PIC 9(4).
>
>
> To save the time I tried this:
>
> ACCEPT TimeStart From Time.
>
> * later...
>
> ACCEPT TimeEnd FROM TIME
> SUBTRACT timestart FROM timeend into timetoal
> DISPLAY timetotal.
>
> But then I get the errorsmessage:
> 'timestart' may not be alphanumeric.
>
> How can I do this?
> Thanks a lot for your help!
>
> Regards,
>
> Dennis
>
This has bitten me on the ass many times with dates and times. Try this:
05 timestart-n redefines timestart pic 9(10).
Now do your math.
John
| |
| Howard Brazee 2007-03-02, 6:55 pm |
| On Fri, 2 Mar 2007 16:46:13 -0500, "John Simpson"
<jasimp@earthlink.net> wrote:
[color=darkred]
>This has bitten me on the ass many times with dates and times. Try this:
> 05 timestart-n redefines timestart pic 9(10).
If TimeEnd = 120000 and TimeStart=110059, what is the desired
TimeTotal? I suspect you don't want 000041.
It's better off to use time functions.
| |
| Howard Brazee 2007-03-02, 6:55 pm |
| On Fri, 02 Mar 2007 14:50:52 -0700, Howard Brazee <howard@brazee.net>
wrote:
>If TimeEnd = 120000 and TimeStart=110059, what is the desired
>TimeTotal? I suspect you don't want 000041.
>
>It's better off to use time functions.
Replace that:
If TimeEnd = 120000 and TimeStart = 115959, you probably don't want
TimeTotal = 4941.
| |
| HeyBub 2007-03-03, 3:55 am |
| Howard Brazee wrote:
> On Fri, 02 Mar 2007 14:50:52 -0700, Howard Brazee <howard@brazee.net>
> wrote:
>
>
>
> Replace that:
> If TimeEnd = 120000 and TimeStart = 115959, you probably don't want
> TimeTotal = 4941.
2 + 2 = 37 is closer than 2 + 2 = purple. Might be good enough.
| |
| John Simpson 2007-03-04, 6:55 pm |
|
"Howard Brazee" <howard@brazee.net> wrote in message
news:6s6hu2tcqgfq0tvptvareq7g38o62vul5u@
4ax.com...
> On Fri, 2 Mar 2007 16:46:13 -0500, "John Simpson"
> <jasimp@earthlink.net> wrote:
>
>
>
>
> If TimeEnd = 120000 and TimeStart=110059, what is the desired
> TimeTotal? I suspect you don't want 000041.
>
> It's better off to use time functions.
I did not even suggest subtracting 110059 from 120000!
|
|
|
|