
Formula to calculate the duration in Hours and minutes of a work
I have to fields "WorkEnd"(End Hour field type) and "WorkStart" (Start Hour Field type), how can i calculate the duration of the work in hours and minutes and show it in a field called "Total"???
Thanks in advance.
-
If you use a Date/Time field, Ninox does the math properly.
I have a test DB with a clockIn field and clockOut field that are Date/Time fields. Then I have another formula field that takes clockOut - clockIn and I get the proper time. Now that you are using Date/Time fields you now have to be aware that Ninox, behind the scenes, uses milliseconds.
Then you have to have another field that converts the milliseconds to a meaningful number: number(HoursWorked / 3600000).
Give it a try and let us know how it goes.
-
Hi
Fred's answer is the correct way to go but if you want to stick to a time field use an if stataement to check if your duration is positive or negative and add 24 to the answer if it's negative. You can see that for your -20.5 above, 24-20.5 gives the correct answer, 3.5..
Doing the same without an if statement can be done with this...
TimeEnd-TimeStart+((sign(TimeEnd-TimeStart)-1)*-12)
Regards John
-
Hello, if it helps, I managed to create a formula to calculate sleep time. I tell myself that this formula can be applied to many other things related to a difference between 2 moments.
if sign(Awakening - Sleep) - 1 then
Awakening - Sleep + 86400000
else
Awakening - Sleep
end + Siesta'The destination field is a formula field.