+ Reply to Thread
Results 1 to 7 of 7

hours between dates??

Hybrid View

spinkung hours between dates?? 07-24-2008, 06:35 AM
arthurbr Right-click and format as... 07-24-2008, 08:01 AM
daddylonglegs To combine a date and time... 07-24-2008, 08:39 AM
sinn3r As for your first question,... 07-24-2008, 08:51 AM
spinkung thanks for all your... 07-24-2008, 09:57 AM
daddylonglegs This is a formatting issue.... 07-24-2008, 10:05 AM
spinkung brilliant, thanks. :) 07-24-2008, 10:10 AM
  1. #1
    Forum Contributor spinkung's Avatar
    Join Date
    10-27-2006
    Posts
    199

    hours between dates??

    Hi all,

    I have 2 questions really but hey are related to the same problem.

    The problem is that i need to calculate the number of hours between 2 dates/times. I have been given the worksheet which has the 4 columns.
    col1 = start date, col2 = start time, col3 = end date, col 4 = end time.

    1) So, the first problem is that i need to concatente the startdate/time and end date/time. When i try this however it converts them into the machine date/time. e.g. =a1 & " " & b1 (a1 = start date, b1 = start time) ...becomes 39448 0.375. Can i avoid this and show them as a date and time.

    2) And secondly i need to then work hours the total number of hours between the two dates excluding weekends??

    Can anybody help on either problem? Many thanks in advance.

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    1) So, the first problem is that i need to concatente the startdate/time and end date/time. When i try this however it converts them into the machine date/time. e.g. =a1 & " " & b1 (a1 = start date, b1 = start time) ...becomes 39448 0.375. Can i avoid this and show them as a date and time.
    Right-click and format as date and time in the format you want

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723
    To combine a date and time you don't concatenate, you add, i.e.

    =A1+B1

    format result cell to show date and time

    ....however, that step is unnecessary if you want to calculate work hours between the start and end times/dates.

    Assuming that your dates won't be at weekends, and you want to count all weekday time (24 hours) you can use this formula

    =NETWORKDAYS(A1,C1)-1+D1-B1

    format result cell as [h]:mm

    Where A1 is start date, B1 start time, C1 end date and D1 end time

    Note: NETWORKDAYS is part of Analysis ToolPak add-in [unless you have Excel 2007, in which case it's an inbuilt function], if not installed use Tools > Add-ins and tick "Analysis ToolPak".

  4. #4
    Registered User
    Join Date
    07-23-2008
    Location
    UAE
    Posts
    12
    As for your first question, let's suppose the date is in column A and the time is in column B, the range starts from row 1:

    =+CONCATENATE(DAY(A1),"-",MONTH(A1),"-",YEAR(A1)," ",HOUR(B1),":",MINUTE(B1))

    Use =Weekdays() for your second question.

  5. #5
    Forum Contributor spinkung's Avatar
    Join Date
    10-27-2006
    Posts
    199
    thanks for all your replies......


    Right-click and format as date and time in the format you want
    This doesn't work it just stays as the machine date and time 3951....


    =NETWORKDAYS(A1,C1)-1+D1-B1
    this one seems to only calculate the difference between the hours without taking in to account the days. e.g. 01/01/08 09:00 - 02/01/08 - 11:00 only returns 2 when it should return 26.


    =+CONCATENATE(DAY(A1),"-",MONTH(A1),"-",YEAR(A1)," ",HOUR(B1),":",MINUTE(B1))
    This works fine but the weekdays() function doesn't seem to appear when i try and use it. It's not in my function library, do i need to add it??


    Many Thanks.

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,723
    Quote Originally Posted by spinkung
    this one seems to only calculate the difference between the hours without taking in to account the days. e.g. 01/01/08 09:00 - 02/01/08 - 11:00 only returns 2 when it should return 26.
    This is a formatting issue. Format result cell as [h]:mm as previously stated and you should see 26:00. The square brackets ensure that the result displays as "elapsed time", i.e. it can display durations greater than 23:59

    Quote Originally Posted by spinkung
    .....but the weekdays() function doesn't seem to appear when i try and use it. It's not in my function library, do i need to add it??
    There is a WEEKDAY function which returns a number from 1 to 7 depending on the day of week but this can't be easily utilised to count weekday hours, for that NETWORKDAYS is preferable, see above.....
    Last edited by daddylonglegs; 07-24-2008 at 10:08 AM.

  7. #7
    Forum Contributor spinkung's Avatar
    Join Date
    10-27-2006
    Posts
    199
    brilliant, thanks.

+ 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