Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Simple Time Duration Calculation

Avatar

Avatar
Validate 10
Level 1
shawnFMU
Level 1

Like

1 like

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 1
shawnFMU
Level 1

Like

1 like

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
shawnFMU
Level 1

11-10-2018

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!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

12-10-2018

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

Answers (4)

Answers (4)

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

17-10-2018

great. Glad it worked out for you.

Avatar

Avatar
Validate 10
Level 1
shawnFMU
Level 1

Like

1 like

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 1
shawnFMU
Level 1

Like

1 like

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
shawnFMU
Level 1

16-10-2018

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!

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct Reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

15-10-2018

Send me your email address and I will send you my sample

Avatar

Avatar
Validate 10
Level 1
shawnFMU
Level 1

Like

1 like

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 10
Level 1
shawnFMU
Level 1

Like

1 like

Total Posts

38 posts

Correct Reply

1 solution
Top badges earned
Validate 10
Validate 1
Boost 1
Affirm 1
View profile
shawnFMU
Level 1

15-10-2018

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