I need a simple Time Duration Calculation. What I've read and piece together, I can't seem to get it to work.
Time2Num and Num2Time...
Help!
In 1 day, Start time and End time equal how much Total time. Example 1:00 to 3:00 equal 2
I've set three Text Fields.
Time1
Time2
Total
Total text field, Calculate event, JavaScript
var start = Time2Num(Time1.formattedValue, "HH:MM")
var end = Time2Num(Time2.formattedValue, "HH:MM")
var dur = Num2Time(end + start, "HH:MM")
this.rawValue = dur;
Thank you in advance!
Solved! Go to Solution.
Views
Replies
Total Likes
Here is a script I used. It was odd that it wasn't working and I realized my form was set as "Static" once I saved it as "Dynamic" it worked.
FormCalc
var a = (Time2Num(Time1.formattedValue)/ (60 * 60 * 1000))
var b = (Time2Num(Time2.formattedValue)/ (60 * 60 * 1000))
$ = b-a
Views
Replies
Total Likes
Here is a script I used. It was odd that it wasn't working and I realized my form was set as "Static" once I saved it as "Dynamic" it worked.
FormCalc
var a = (Time2Num(Time1.formattedValue)/ (60 * 60 * 1000))
var b = (Time2Num(Time2.formattedValue)/ (60 * 60 * 1000))
$ = b-a
Views
Replies
Total Likes
sorry. No luck here. straight copy and paste. formCalc check; "dynamic" check; "calculate" event check;
- syntax double checked... to my best abilities...
- wrote out the references... "form1.Page1.Time1.formattedValue"
I tried with normal Text Field.
then flipped to a Date/Time Field with time set in the binding. a normal pattern selected in the display tab.
"0" is displayed in the total field... that's good.
what's your Fields like? Text or Date/Time?
how are you inputting your value? "12" & "1" or "12:00" & "1:00"
So, I imagine Time2Num is taking a time formatted value and converting it to a numeric value... and
Num2Time is numeric value to a time format...?
Views
Replies
Total Likes
Send me your email address and I will send you my sample
Views
Replies
Total Likes
It works!
turns out you need to set your input field as a Date/Time Field, BUT leave the Patterns setting empty.
I guess the script takes whatever default setting the Date/Time Field uses... go figure... seems counter intuitive to me...
Thank you very much mouslander!
Views
Replies
Total Likes
great. Glad it worked out for you.
Views
Replies
Total Likes