+ Reply to Thread
Results 1 to 9 of 9

Need a function that calculates time between 2 dates

  1. #1
    Registered User
    Join Date
    06-30-2006
    Posts
    3

    Need a function that calculates time between 2 dates

    I have been playing around with a function that will give me the difference between to dates and times.

    Example:
    A1 contains 6/10/06 10:00AM
    A2 contains 6/13/06 10:00PM

    I am trying to get a function to give me an answer with how many days, hours and minutes between the 2 dates/times.

    the answer would be 3 days, 12 hours, 0 minutes

  2. #2
    MartinW
    Guest

    Re: Need a function that calculates time between 2 dates

    Hi Rawis,

    In A3 put =A2-A1
    And format cell as custom d:hh:mm for 3:12:00 or
    dd:hh:mm for 03:12:00

    HTH
    Martin



  3. #3
    Registered User
    Join Date
    06-30-2006
    Posts
    3
    anyway to make it say days after days, hours after hours,etx

  4. #4
    RagDyeR
    Guest

    Re: Need a function that calculates time between 2 dates

    Check out this link:

    http://www.cpearson.com/excel/datedif.htm

    --

    HTH,

    RD
    =====================================================
    Please keep all correspondence within the Group, so all may benefit!
    =====================================================

    "RawisTheGameHhH"
    <[email protected]> wrote in
    message news:[email protected]...

    I have been playing around with a function that will give me the
    difference between to dates and times.

    Example:
    A1 contains 6/10/06 10:00AM
    A2 contains 6/13/06 10:00PM

    I am trying to get a function to give me an answer with how many days,
    hours and minutes between the 2 dates/times.

    the answer would be 3 days, 12 hours, 0 minutes


    --
    RawisTheGameHhH
    ------------------------------------------------------------------------
    RawisTheGameHhH's Profile:
    http://www.excelforum.com/member.php...o&userid=35945
    View this thread: http://www.excelforum.com/showthread...hreadid=557337



  5. #5
    Bob Phillips
    Guest

    Re: Need a function that calculates time between 2 dates

    Just subtract one from the other and format as

    d "days, " h "hours, " m "mins, " s "secs"

    This falls down if more than 31 days are betgween dates though, where you
    would need

    =INT(A2-1)-INT(A1+1)+(MOD(A2,1)+(1-MOD(A1,1))>=1)&" days "&
    TEXT(MOD((MOD(A2,1)+(1-MOD(A1,1))),1),"h ""hours, "" m ""mins, "" s
    ""secs""")

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "RawisTheGameHhH"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > I have been playing around with a function that will give me the
    > difference between to dates and times.
    >
    > Example:
    > A1 contains 6/10/06 10:00AM
    > A2 contains 6/13/06 10:00PM
    >
    > I am trying to get a function to give me an answer with how many days,
    > hours and minutes between the 2 dates/times.
    >
    > the answer would be 3 days, 12 hours, 0 minutes
    >
    >
    > --
    > RawisTheGameHhH
    > ------------------------------------------------------------------------
    > RawisTheGameHhH's Profile:

    http://www.excelforum.com/member.php...o&userid=35945
    > View this thread: http://www.excelforum.com/showthread...hreadid=557337
    >




  6. #6
    MartinW
    Guest

    Re: Need a function that calculates time between 2 dates

    Re-reading your post also try custom d"days"hh"hours"mm"mins"

    HTH
    Martin



  7. #7
    Registered User
    Join Date
    06-30-2006
    Posts
    3
    Quote Originally Posted by MartinW
    Re-reading your post also try custom d"days"hh"hours"mm"mins"

    HTH
    Martin
    you guys are great! anyway to have it so it wont count the weekends?

  8. #8
    Bob Phillips
    Guest

    Re: Need a function that calculates time between 2 dates

    Only upto 31 days

    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "MartinW" <[email protected]> wrote in message
    news:[email protected]...
    > Re-reading your post also try custom d"days"hh"hours"mm"mins"
    >
    > HTH
    > Martin
    >
    >




  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Quote Originally Posted by RawisTheGameHhH
    anyway to have it so it wont count the weekends?
    assuming both A1 and A2 are on weekdays

    =(NETWORKDAYS(A1,A2)-1)+MOD(A2,1)-MOD(A1,1)

    format as before

+ 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