The time is part of the full date specification, so a time is a date regardless of its visible format. I'm confused why you want to recalculate the end time when you already have it. The text in the field is still available whether the user can see the field or not.
It would help if we knew the overall goal. What does this stack do, exactly? When you say you want to calculate the elapsed time, do you mean you want to figure out the time of day the elapsed time is (which is already available in the end time field) or do you mean you just want to display elapsed time in the hh:mm:ss format?
Help with calculating answer from Field inputs [SOLVED]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Help with calculating answer from Field inputs
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Help with calculating answer from Field inputs
Thank you Jaques.
I thought I would start here first as this is exactly what I'm after:
....do you mean you just want to display elapsed time in the hh:mm:ss format
Yes I do.
I have never brought hh:mm:ss into my questions (which I would if it was Excel) as in all the hours I have read, re-read and then tested from the livecode examples, I have never come across mention of hh:mm:ss
I don't believe my overall goal is important at this learning stage, as I'm presently after an answer to the elapsed time part before I move onto my next learning curve relating to distance.
On the code in my last Post above I have the correct field answer to total seconds in the line below:
put tSecondsPassed into field "tSecondsPassed"
The two lines below are not giving me what I'm after as not only is it displayed in this format 4:00 AM but also on certain field "ReleasedM" and "ArrivedM" inputs the answer is incorrect as Jean-Marc pointed out.
convert tSecondsPassed from seconds to time
put tSecondsPassed into field "myNewField"
I do hope Jaques your able to solve how "myNewField" will not only display in hh:mm:ss format but also with the correct answer.
I do thank everyone for their patience with this old lady, it's very much appreciated.
Regards,
Ruth
I thought I would start here first as this is exactly what I'm after:
....do you mean you just want to display elapsed time in the hh:mm:ss format
Yes I do.
I have never brought hh:mm:ss into my questions (which I would if it was Excel) as in all the hours I have read, re-read and then tested from the livecode examples, I have never come across mention of hh:mm:ss
I don't believe my overall goal is important at this learning stage, as I'm presently after an answer to the elapsed time part before I move onto my next learning curve relating to distance.
On the code in my last Post above I have the correct field answer to total seconds in the line below:
put tSecondsPassed into field "tSecondsPassed"
The two lines below are not giving me what I'm after as not only is it displayed in this format 4:00 AM but also on certain field "ReleasedM" and "ArrivedM" inputs the answer is incorrect as Jean-Marc pointed out.
convert tSecondsPassed from seconds to time
put tSecondsPassed into field "myNewField"
I do hope Jaques your able to solve how "myNewField" will not only display in hh:mm:ss format but also with the correct answer.
I do thank everyone for their patience with this old lady, it's very much appreciated.
Regards,
Ruth
Re: Help with calculating answer from Field inputs
There are more and more old men here. We need all the old ladies we can get.
Craig
Craig
Re: Help with calculating answer from Field inputs
If it is just a display issue, then the handler segment I posted before will do the job, you only need to add the hours to it:
This gets the number of seconds that have elapsed from a field named "secondsPassed" and constructs a string in the format you want. There is no automatic way to do it outside of just doing the math. There are 3600 seconds in an hour. The "div" command does a division and drops any remainder, giving you a whole number for the hours and minutes. The "mod" command does a division and drops the integer, leaving only the remainder. That gives us any remaining seconds. The resulting calculations are then strung together into a text representation and put into the display field.
See "mod" and "div" in the dictionary.
Code: Select all
put fld "secondsPassed" into tElapsed
set the numberformat to "00"
put tElapsed div 3600 into tHrs
subtract (tHrs * 3600) from tElapsed
put tElapsed div 60 into tMins
put tElapsed mod 60 into tSecs
put tHrs & colon & tMins & colon & tSecs into fld "myNewField"
See "mod" and "div" in the dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Help with calculating answer from Field inputs
Thank you so much Jacque, it was most kind and I can now move onto my distances learning curve.
With my kind regards,
Ruth
With my kind regards,
Ruth