+ Reply to Thread
Results 1 to 4 of 4

Calculate number of hours from Start date and time and End date and time

  1. #1
    Registered User
    Join Date
    03-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    19

    Calculate number of hours from Start date and time and End date and time

    Hi,

    What I've done in my office now is create a google form for my employees to fill in their overtime claims. They enter the date and time that they worked. I copy the data from the google spreadsheet onto excel.

    I need a formula that will calculate the number of hours from the start time and end time.

    An example of what it looks like is :

    Cell N2: 29/5/2013 5:30:00 PM ---> start time
    Cell O2: /5/2013 8:30:00 PM ---> end time


    So for the example above, it should be 3 hours. I also need the formula to work for when it goes over night. For example :

    Cell N2: 29/5/2013 10:30:00 PM ---> start time
    Cell O2: 30/5/2013 12:30:00 AM ---> End time


    I have formatted the start and end cells as d/m/yyyy h:mm


    Thanks!

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Calculate number of hours from Start date and time and End date and time

    hi sathyasun. it is perfect when you have both the dates & time in 1 cell. so just do:
    =O2-N2

    format as:
    [h]:mm

    the square brackets allows displaying of equal or more than 24 hours.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    03-29-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Calculate number of hours from Start date and time and End date and time

    Thanks alot benishiryo!

    Your formula and formatting worked!

    However, my problem now is, I need to multiply the number of hours with another number to calculate how much they should be paid. This is not working because of the formatting. Do you know how I could resolve this?

    What I've tested is for a total overtime of 35 hours but excel is taking it as 1.4583333. I'm guessing thats the number of days.

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Calculate number of hours from Start date and time and End date and time

    you're very welcome. Excel recognises dates as integers & time as decimals. to verify, type in 1jan2013 in A1. and 12 pm in B1. Format both cells to General. you will see that A1 is 41275 (meaning 41,275th day from 1 Jan 1900) & B1 is 0.5 (1/2 a day).*

    so if you need it in hours, simply multiply it by 24.
    =(O2-N2)*24
    format to General. now if you see 2.5, it is not referring to 2 hours & 50 minutes, but 2 hours & 30 minutes because 0.5 is a fraction of an hour.
    i guess you would have to round your formula if you need just the hours. you can use formulas like ROUND, ROUNDUP, ROUNDDOWN.

    please mark this thread as "Solved" if nothing else. if you have another question not relating to the title, please start a new thread

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1