0

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.

11replies Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
    • Nick
    • Nick
    • 4 yrs ago
    • Reported - view

    Try this formula

    WorkEnd - WorkStart

    Like
  • I put in the duration field called 'Total', the formula Total = WorkEnd - WorkStart

    It does not work...

    Like
    • Nick
    • Nick
    • 4 yrs ago
    • Reported - view

    Screen Shot 2019-03-06 at 20.07.13

    Like
  • Ok, thanks a lot

    Like
  • How to convert this (8:30) to 8,5 ours, so I can get a price for spended time?

    Like
    • Mconneen
    • Mconneen
    • 2 yrs ago
    • Reported - view

    @Jan, 

    Use a Time Interval field.    Then set that field equal to the end time - start time.... and select the desired format.   POOF. 

    2020-05-31_15-26-34

    Like
  • What??
    If I am gonna entertain in a pub for an example, I usally starts around 22:00 (PM) and play until 01:30 (AM), okay?
    The answer is gonna be "-20.5 h", how do you explain that??

    Like
  • @Mconneen

    Like
    • Fred
    • Fred
    • 1 yr ago
    • Reported - view

    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.

    Like
  • 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

    Like
  • 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.

    Like
Like Follow
  • 1 mth agoLast active
  • 11Replies
  • 3203Views
  • 1 Following