+ Reply to Thread
Results 1 to 6 of 6

calculate number of years,months,days,hours,minutes and seconds between 2 dates

Hybrid View

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    65

    calculate number of years,months,days,hours,minutes and seconds between 2 dates

    Ive been scratching my head for ages, i can calculate number of years,months and days betwen 2 date stamps
    I can calculate the number of hours, minutes, seconds between 2 time stamps

    BUT when i have 01/05/2017 12:27:45 MINUS 04/07/2010 13:45:34 how do i display this as X years, X months, X days, X hours, X minutes, X seconds?

    Any help is appreciated!

  2. #2
    Forum Contributor shivya's Avatar
    Join Date
    08-19-2017
    Location
    Delhi, India
    MS-Off Ver
    2013
    Posts
    240

    Re: calculate number of years,months,days,hours,minutes and seconds between 2 dates

    For years =YEAR(B1)-YEAR(E1)

    For days =DAYS(B1,E1)

    For time =F1-C1

  3. #3
    Registered User
    Join Date
    03-26-2016
    Location
    São Paulo - Brazil
    MS-Off Ver
    2016
    Posts
    48

    Re: calculate number of years,months,days,hours,minutes and seconds between 2 dates

    rikkyshh

    Watch this Link

    https://www.mrexcel.com/forum/excel-...s-minutes.html

    I hope I have helped

    Decio

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,873

    Re: calculate number of years,months,days,hours,minutes and seconds between 2 dates

    The formula here was wrong. See explanation in next posts.
    Last edited by Kaper; 10-21-2017 at 10:28 AM. Reason: deleted wrong formula
    Best Regards,

    Kaper

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,787

    Re: calculate number of years,months,days,hours,minutes and seconds between 2 dates

    Quote Originally Posted by Kaper View Post
    =TEXT(B1-A1,"yy\y mm\m dd\d hh\h mm\m ss\s")
    .....but this always gives you the wrong number of months (because it always gives you a value in the range 1-12 instead of 0-11 as required) e.g. when the actual difference is 20 days this shows 1 month and 20 days....

    It's possible to use the TEXT function for hours, minutes and seconds but you probably need something else for years, months and days, e.g.

    =DATEDIF(A1,B1,"y")&" Years, "&DATEDIF(A1,B1,"ym")&" Months, "&DATEDIF(A1,B1,"md")&" Days"&TEXT(B1-A1," h"" Hours ""m"" Minutes ""s"" Seconds""")
    Last edited by daddylonglegs; 10-21-2017 at 10:07 AM.
    Audere est facere

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,873

    Re: calculate number of years,months,days,hours,minutes and seconds between 2 dates

    Whoops, indeed - also days make problem (except 0 days). So indeed - wrong result.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Calculate the number of days, hours, minutes and second between two dates
    By Trelacmv in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-12-2017, 06:26 AM
  2. Convert a value to Years, Months, Days, Hours and Minutes
    By )3az_)3aziah in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-30-2017, 11:18 AM
  3. Replies: 8
    Last Post: 02-20-2014, 05:46 PM
  4. Replies: 11
    Last Post: 01-13-2013, 09:40 AM
  5. Convert days -> Years, Months, Days, Hours, Minutes, Seconds
    By brharrii in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2012, 06:44 PM
  6. Replies: 1
    Last Post: 11-02-2011, 06:50 PM
  7. Replies: 1
    Last Post: 11-02-2011, 06:44 PM

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