The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Spreadsheet Help

Roland of GileadRoland of Gilead Registered User regular
edited December 2006 in Help / Advice Forum
Ok. I'm Building a timecard and I'm having a brain fart.

I've got two fields One for Start Time and one for End time. Both are Formatted HH:MM AM/PM I want to write a function to add up the hours worked and I can't seem to make it work. It needs to work across midnight as we often work 12+ hour shifts overnight. I know theres an easy way to do this as I've done it before but I can't seem to get it to go.

Barneysig.jpg
Roland of Gilead on

Posts

  • SerpentSerpent Sometimes Vancouver, BC, sometimes Brisbane, QLDRegistered User regular
    edited December 2006
    subtract, multiply by 24, use the 'number' format for the result, not 'date'.

    edit: you'll also want to put the 'day' in the field, not just hour.

    Serpent on
  • Blake TBlake T Do you have enemies then? Good. That means you’ve stood up for something, sometime in your life.Registered User regular
    edited December 2006
    Just a guess.

    IF(A<B,B-A,Midnight-A+B)

    Blake T on
  • Roland of GileadRoland of Gilead Registered User regular
    edited December 2006
    Serpent wrote:
    subtract, multiply by 24, use the 'number' format for the result, not 'date'.

    edit: you'll also want to put the 'day' in the field, not just hour.

    Could you elaborate on this a bit?

    Roland of Gilead on
    Barneysig.jpg
  • OrogogusOrogogus San DiegoRegistered User regular
    edited December 2006
    What about something like this?

    =IF(HOUR(C3)-HOUR(B3)<0, 24 + HOUR(C3)-HOUR(B3), HOUR(C3)-HOUR(B3))

    Change the cell references to match, obviously.

    Orogogus on
Sign In or Register to comment.