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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

FormCalc - How to calculate difference between two datetime fields in HH:MM ?

Marcos_J_Pinto
Level 5
Level 5

Hello!

I'm building a timesheet form in which I need to calculate the difference between start and end times and present the result.

I'm trying to do this with FormCalc but if it is easier with JS it's ok too.

So this is what I did on the total field, using the calculate event on a NUMERIC field called decimalValue:

     elapsed = Time2Num(endTime.formattedValue, "HH:MM") - Time2Num(startTime.formattedValue, "HH:MM")

 

And then I tried to convert into a time field:

     total = decimalValue.rawValue;

     $.formattedValue = Num2Time(total, "HH:MM")

Well, it doesn't work, it gives me crazy results in the datetime (total) field. If I type 09:00 and 09:30, the end result is... 22:30. Huh?

 

Please, could someone help me understand how this thing works? 

 

Thank you very much for any hints!

 

Marcos

1 Accepted Solution
Niall_O_Donovan
Correct answer by
Level 10
Level 10
2 Replies
Niall_O_Donovan
Correct answer by
Level 10
Level 10
Marcos_J_Pinto
Level 5
Level 5

Thank you NIall!

Always coming to the rescue! Thanks!!

Marcos