+ Reply to Thread
Results 1 to 9 of 9

Finding time intervals in excel

  1. #1
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Finding time intervals in excel

    Hello,

    I'm trying to create a spreadsheet for a workweek. The program will need to calculate the total number of hours worked in a given day, determine if it is greater or less than 6 hours, if greater subtract 30 minutes for a break, if less do nothing, and return a total number of hours worked in number format.

    For example, a user will input an employee as working 8am - 5pm. The program then should output 8.5. Then, add all hours together for a week and output total hours working in number format. Example, 20.5.

    I'm using excel 2007, but i also need it to work in earlier versions such as excel 2001.

    Thanks

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Finding time intervals in excel

    Hi and welcome to the board

    Perhaps
    Please Login or Register  to view this content.
    ( keeps time as sexagesimal)

    Sum the daily results and multiply the sum by 24 - Format as number

  3. #3
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Finding time intervals in excel

    Quote Originally Posted by arthurbr View Post
    Hi and welcome to the board

    Perhaps
    Please Login or Register  to view this content.
    ( keeps time as sexagesimal)

    Sum the daily results and multiply the sum by 24 - Format as number
    Thanks this is a lot cleaner then the way i got to do it. Now i'm setting up a weekly schedule spreadsheet. Suppose an employee does not work a day and i want to put an "X" instead. For example, i have 8:00 AM - 2:00 PM in three cells (cell 1: 8:00 am, cell 2: -, cell 3: 2:00). If a person dosent work then i wanna put in "x" or maybe x-x. How will this affect the formula, i basically want it to be omitted from all calculations and the and the sum still be returned for other days.

  4. #4
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Finding time intervals in excel

    1. Please do not quote entire posts - I wonder in which color it should be written so that posters see the request in my sig !
    2, Using the range form of the sum function ( i.e. SUM(A1:B5) ) does not " see" cells containng text, so, np.

  5. #5
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Finding time intervals in excel

    The problem i am having is that im trying to sum up the results of 7 different if statements for 7 different days. If one of the days is left blank, then the if statement returns zero and there is no problem, but for placeholder purposes i want to put an X. When this happens the if statement for this day returns "#VALUE!" and as a result makes the sum of the entire week return #VALUE!
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Finding time intervals in excel

    You can amend as follows :
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Re: Finding time intervals in excel

    Awesome this works perfectly!

    One final question, how can i format a time cell to display just the first leading digit. For example, 8:00am - 4:30 pm i would like to be displayed as follows, 8-4:30, to save space.

    If this is not possible then is there a formula to convert time to a number as follows: 8:00 am or pm to 8, and 4:30 am or pm to 4:30.

  8. #8
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Finding time intervals in excel

    I would suggest formatting your time in the 24-hour system instead of the 12 hr or custom format your cells as hh instead of hh:mm. The underlying value will not change ( but is that really a good idea?)

    To convert time to a decimal number, multiply by 24 and format as number ( 4:30 will become 4.5 of course)

  9. #9
    Registered User
    Join Date
    01-09-2013
    Location
    Vientiane, Laos
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Finding time intervals in excel

    as was already said, Excel can calculate time intervals correctly but the problem is they do not display correctly.

    for example if one enters two date date/time values in two different cells,and enters a formula a third cell to calculate the difference, the result will be displayed in days if the result cell is formatted as a number :

    09-Jan-13 - 07-Jun-64 = 17,748.60

    obviously this is not much use. so we must display the 17,749.60 as a meaningful number

    this can be done in a number of ways, but in general the concept is simple : divide the number of days by a commonly used time period.

    following is a formula that converts the 17,749.60 into a cell that displays 48Y 7M 18D 14H

    while fairly long and complex, it should give you the idea. note that value of cell B15 in the formula is 09-Jan-13 and the value of cell B2 in the formula is 07-Jun-64

    also remember that the default hh:mm:ss is 1200 (most of us call it midnight) if these are not entered as part of the date/time value

    =ROUNDDOWN((B$15-B2)/365,0)&"Y"&" "&ROUNDDOWN(((B$15-B2)-ROUNDDOWN((B$15-B2)/365,0)*365)/30,0)&"M"&" "&ROUNDDOWN((B$15-B2)-ROUNDDOWN((B$15-B2)/365,0)*365-ROUNDDOWN(((B$15-B2)-ROUNDDOWN((B$15-B2)/365,0)*365)/30,0)*30,0)&"D"&" "&ROUNDDOWN(((B$15-B2)-(ROUNDDOWN((B$15-B2)/365,0)*365)-(ROUNDDOWN(((B$15-B2)-ROUNDDOWN((B$15-B2)/365,0)*365)/30,0)*30)-ROUNDDOWN((B$15-B2)-ROUNDDOWN((B$15-B2)/365,0)*365-ROUNDDOWN(((B$15-B2)-ROUNDDOWN((B$15-B2)/365,0)*365)/30,0)*30,0))*24,0)&"H"
    Last edited by Macmtn; 01-09-2013 at 03:23 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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