Military Time Calculation: Night Shift
I have columns set up in 4-digit military time. The formula below calculates day shift (0800 to 1700), but returns a negative value when calculating night shift (2200 to 0600). How can this be resolved?
=((VALUE(LEFT([End Time 1]@row, 2)) + VALUE(RIGHT([End Time 1]@row, 2)) / 60) - (VALUE(LEFT([Start Time 1]@row, 2)) + VALUE(RIGHT([Start Time 1]@row, 2)) / 60))
Thank you,
Morgan
Best Answers
-
Morgan;
Try this (it probably needs some error checking to clean it up):
=IF([End time 1]@row > [Start time 1]@row, ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60)), (24 + ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60))))
Just beware, right now a zero minute shift will look 24 hours long. You probably need to nest another IF to deal with that!
Dale
-
DMurphy,
Thank you... it worked. Now about that pesky additional nested IF
-
=IF([End time 1]@row = [Start time 1]@row, 0, (IF([End time 1]@row > [Start time 1]@row, ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60)), (24 + ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60))))))
... should deal with it ...
Cheers,
Dale
Answers
-
Try this:
=IF(VALUE([start time]@row)<=value([end time]@row, VALUE(LEFT([End Time 1]@row, 2)) - VALUE(LEFT([Start Time 1]@row, 2), 24 -VALUE(LEFT([Start Time 1]@row, 2) + VALUE(LEFT([End Time 1]@row, 2))) + ABS((Value(Right([start time]@row, 2)) -value(right([end time]@row, 2)))/60
It will give you hours and fractions between the 2 military times.
Work?
Mark
I'm grateful for your "Vote Up" or "Insightful". Thank you for contributing to the Community.
-
Hi Mark,
The formula returned an error of #UNPARSEABLE.
Morgan
-
Morgan;
Try this (it probably needs some error checking to clean it up):
=IF([End time 1]@row > [Start time 1]@row, ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60)), (24 + ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60))))
Just beware, right now a zero minute shift will look 24 hours long. You probably need to nest another IF to deal with that!
Dale
-
DMurphy,
Thank you... it worked. Now about that pesky additional nested IF
-
=IF([End time 1]@row = [Start time 1]@row, 0, (IF([End time 1]@row > [Start time 1]@row, ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60)), (24 + ((VALUE(LEFT([End time 1]@row, 2)) + VALUE(RIGHT([End time 1]@row, 2)) / 60) - (VALUE(LEFT([Start time 1]@row, 2)) + VALUE(RIGHT([Start time 1]@row, 2)) / 60))))))
... should deal with it ...
Cheers,
Dale
-
DMurphy,
Perfection! You're the best!
Thank you so much!
-
Morgan;
Great! Happy to help.
Btw, you should be able to convert that into a column formula to make it more reliable.
Cheers,
Dale
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!