Formula for calculating total time between two military times

Ami Veltrie
Ami Veltrie ✭✭✭✭✭✭
edited 02/19/24 in Formulas and Functions

Building a 'time tracker' to calculate total hours worked. Can someone help correct my formula(s)?

I'm using formulas found in this community but I might not be using them correctly. I'm expecting the Hours column to display "10.71" not "109.72".

Clock in Time:

=RIGHT(Created@row, 8)

Clock In (Military):

=((VALUE(LEFT([Clock In Time]@row, FIND(":", [Clock In Time]@row) - 1)) - IF(VALUE(LEFT([Clock In Time]@row, FIND(":", [Clock In Time]@row) - 1)) = 12, 12, 0) + IF(RIGHT([Clock In Time]@row, 2) = "pm", 12, 0)) + MID([Clock In Time]@row, FIND(":", [Clock In Time]@row) + 1, 2))

Clock Out (Military):

=((VALUE(LEFT([Clock Out Time]@row, FIND(":", [Clock Out Time]@row) - 1)) - IF(VALUE(LEFT([Clock Out Time]@row, FIND(":", [Clock Out Time]@row) - 1)) = 12, 12, 0) + IF(RIGHT([Clock Out Time]@row, 2) = "pm", 12, 0)) + MID([Clock Out Time]@row, FIND(":", [Clock Out Time]@row) + 1, 2))

Minutes:

=(VALUE(LEFT([Clock Out (Military)]@row, IF(LEN([Clock Out (Military)]@row) = 3, 1, 2)) + (VALUE(RIGHT([Clock Out (Military)]@row, 2)) / 60)) - (VALUE(LEFT([Clock In (Military)]@row, IF(LEN([Clock In (Military)]@row) = 3, 1, 2)) + (VALUE(RIGHT([Clock In (Military)]@row, 2)) / 60)))) * 60

Hours:

=Minutes@row / 60


Best Answer

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭
    Answer ✓

    It looks like you have some parenthesis off in the Minutes column.

    =((VALUE(LEFT([Clock Out (Military)]@row, IF(LEN([Clock Out (Military)]@row) = 3, 1, 2))) + (VALUE(RIGHT([Clock Out (Military)]@row, 2)) / 60)) - (VALUE(LEFT([Clock In (Military)]@row, IF(LEN([Clock In (Military)]@row) = 3, 1, 2))) + (VALUE(RIGHT([Clock In (Military)]@row, 2)) / 60))) * 60

    Come see me in Seattle at ENGAGE 2024! I will be at the 10xViz partner booth throughout as well as the "Lets Talk About Community" Meet & Eat table on Tuesday from 11:45am - 12:45pm!

    CERTIFIED SMARTSHEET PLATINUM PARTNER

    10xViz.com

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!