Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Time operations
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



Report this thread to moderator Post Follow-up to this message
Old Post
Dennis Dahn
03-02-07 12:55 PM


Re: Time operations
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
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jack Klappe
03-02-07 12:55 PM


Re: Time operations
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... 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jack Klappe
03-02-07 12:55 PM


Re: Time operations
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.




Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
03-02-07 11:55 PM


Re: Time operations
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 "second
s
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
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
03-02-07 11:55 PM


Re: Time operations
"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



Report this thread to moderator Post Follow-up to this message
Old Post
John Simpson
03-02-07 11:55 PM


Re: Time operations
On Fri, 2 Mar 2007 16:46:13 -0500, "John Simpson"
<jasimp@earthlink.net> wrote:

 

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

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
03-02-07 11:55 PM


Re: Time operations
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
03-02-07 11:55 PM


Re: Time operations
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.



Report this thread to moderator Post Follow-up to this message
Old Post
HeyBub
03-03-07 08:55 AM


Re: Time operations
"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!



Report this thread to moderator Post Follow-up to this message
Old Post
John Simpson
03-04-07 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:48 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.