Comments on: Excel DATEDIF to calculate date difference in days, weeks, months or years

In this tutorial, you will find a simple explanation of the Excel DATEDIF function and a few formula examples that demonstrate how to compare dates and calculate the difference in days, weeks, months or years. Continue reading

Comments page 4. Total comments: 292

  1. I want to equal 1 year to date

  2. Hi,
    This formula =NOW()-A1 does not work for same day calculation:

    if today is 18 Mar 2018, the result shows a month!

    For example A1 is 18 Mar 2018 07:10:00PM

  3. Hi,
    Can someone help me to that I want to find the days in between my start date & today date.
    I tried

    =DATEIF(today(), “3/6/2018” , “d”)
    But the result is #NAME?
    Thanks!

    1. Hi Mavis,

      Please first note that you have a typo in the function name. Besides, if your start date is prior the today's date, you need to change the position of the formula arguments. Thus, the correct formula should look like this:

      =DATEDIF("3/6/2018",TODAY(),"d")

      Hope this will work for you.

  4. how to set age limit for ex: 25.3.1978 to 15.4.1983, if age is between 35 to 40, i have to set 35 how to do it

  5. Hi there. Newbie to Excel, so no expert by any stretch. I'm trying to work out how to do a formula to count days within a month only. I have two columns titled "Start Date" and "Finish Date". For example. Start Date is 22 Jan 18 and Finish Date is 11 Feb 18. Is there a formula to count the number of days (within those two columns) for the month of January 2018 only? It would equal 9 days. I then need another formula, same example as above, to calculate the days that would be returned for February 2018 only, ie. would equal 10 days. The total amount of lines within the speadsheet could be anywhere up to 500 lines. I have found formulas to count the total days, but not exactly for a month only. Hope that makes sense. Thanks.

  6. What about if you use the month of February. If you deduct 28 feb 2018 and 31 Jan 2018 it will be zero month

  7. Hi,

    How to calculate difference in two dates in days when the date is selected/inserted from calendar through Microsoft Date and Time Picker Control.
    This formula is not working =DATEDIF(A2, B2, "d") because it is not considering cell to the cell where date is selected from picker.

    Thanks

  8. Hi, I got a problem in calculating for year month. I would like to add one month for every month.

    Example:20Yr(s) 4 Mth(s)
    (I would like to auto add one month for the example. Please give me the formula).

    thanks.

  9. Here's my version:

    =
    IF(DATEDIF(A2,B2,"y")>1,DATEDIF(A2,B2,"y")&" years, ",
    IF(DATEDIF(A2,B2,"y")=1,DATEDIF(A2,B2,"y")&" year, ",
    IF(DATEDIF(A2,B2,"y")1,DATEDIF(A2,B2,"ym")&" months, ",
    IF(DATEDIF(A2,B2,"ym")=1,DATEDIF(A2,B2,"ym")&" month, ",
    IF(DATEDIF(A2,B2,"ym")1,DATEDIF(A2,B2,"md")&" days",
    IF(DATEDIF(A2,B2,"md")=1,DATEDIF(A2,B2,"md")&" day",
    IF(DATEDIF(A2,B2,"md")<1,"")))

    1. My previous post got scrambled in translation, hope this one works:

      =
      IF(DATEDIF(A2,B2,"y")>1,DATEDIF(A2,B2,"y")&" years, ",
      IF(DATEDIF(A2,B2,"y")=1,DATEDIF(A2,B2,"y")&" year, ",
      IF(DATEDIF(A2,B2,"y")1,DATEDIF(A2,B2,"ym")&" months, ",
      IF(DATEDIF(A2,B2,"ym")=1,DATEDIF(A2,B2,"ym")&" month, ",
      IF(DATEDIF(A2,B2,"ym")1,DATEDIF(A2,B2,"md")&" days",
      IF(DATEDIF(A2,B2,"md")=1,DATEDIF(A2,B2,"md")&" day",
      IF(DATEDIF(A2,B2,"md")<1,"")))

  10. I have a project in which employee should be sent medical test for evey 3years(i.e.one day before completion of 3years) which formula should I use.ex...ajay medical test on 1/01/2014 next check up will be on 31/12/2017... Eagerly waiting for reply

    1. Hello,

      Please try the following formula:

      =TEXT(EDATE(A1,12*3)-1,"dd/mm/yyyy")

      Hope it will help you.

  11. I find the date functions flawed as they take an extra day away from the result.

    01-NOV-2017 to 30-NOV-2017 should be 30 days, but every calculation I use shows 29. Why are the date functions missing a day?

  12. I want to do the same but count the number of months going forward from say Aug to May in that format... Any thoughts?

    1. Hello,

      If I understand your task correctly, please try the following formula:

      =DATEDIF(DATE(2016,8,31),DATE(2017,5,1),"M")

      Hope this will help you!

  13. Hi! Thanks for these instructions - the site/tutorials are great and I've learned a lot! I was wondering if you had any tips for me:
    I am trying to display the date, that is x number of days after Jan 1.

    I used:
    A1 =datedif("01/01/2017","11/27/2017", "d")
    to display how many days it has been since the start of the year.
    I am now trying to display the date 30 days prior.
    I was able to find the day number this year by:
    =datedif("1/1/17", A1, "d")- 30
    For instance, this equals 300. How do I display the 300th day of the year (i.e. October 27)?
    Thanks!

  14. How to calculate time in excel such as
    31/10/17 10:45:00

    01/11/17 02:15:21

    Please advise us above query

    1. Hello, Ahmer,

      Please try the following formula:

      =DAYS("01/11/17 02:15:21"-"31/10/17 10:45:00",0)*24 + HOUR("01/11/17 02:15:21"-"31/10/17 10:45:00") & " hours " & MINUTE("01/11/17 02:15:21"-"31/10/17 10:45:00") & " minutes " & SECOND("01/11/17 02:15:21"-"31/10/17 10:45:00") & " seconds"

      Hope it will help you.

  15. I am using the datedif function to calculate years of service for employment. I have that part down with the exception of employees that had a break in service. How do I add their previous years served before their break in service to their current years of service?

    1. Example:
      Current Date of Hire: 9/25/1999 to Present
      Current Time in Service: 18Y, 1M
      Previous Date of Hire: 5/23/1987
      Previous Termination Date:9/20/1991
      Previous Time in Service: 4Y, 3M

      How to I create a formula to add the current time in service along with the previous time in service?

  16. The datedif function no longer exists inf Office 2016. As usual, when the imbeciles at Microsoft "improve" a product, they remove useful functions.

    1. Hi Wayne,

      DATEDIF still works in Excel 2016. But it is undocumented, meaning you won't find it in the list of functions. To use DATEDIF in your formulas, you need to remember its syntax and type all the arguments manually.

  17. I'm trying to do this in excel but it doesn't give me the option for DATEDIF, only DATE or DATEVALUE...so I'm not sure what to do. Do you guys have a different formula that I can use without that function?

    Weird because I have the newest version...

  18. can any one help me for Excel formula with using IF STATEMENT for calculate tax 5% on OR BEFORE dt 14/9/2017 & 6% if dt 15 or after 15/9/2017
    A B C D
    1 DATE AMOUNT 5% TAX 6% TAX
    2 5/9/2017 2500 ?Formula ?Formula If date A column less than
    3 14/9/2017 1000 15/9/2017 tax 5% oterwise 6%
    4 15/9/2017 1000
    5 26/5/2017 1000
    6 15/10/2017 7000

  19. The most relevant unit of time measure for me is months between start and ending dates. Excel has a function, DATEDIF, which on surface sounds simple:

    =DATEDIF(‘Start Date’,’End Date’,M) will report the number of complete months between dates.
    That works 95% of the time but sometimes contracts cross leap years or they don’ start on the 1st day of the month or end on the last day of month.

    Here is my solution
    =ROUND(IF(TEXT(YEAR('Start Date'),0)&TEXT(MONTH('Start Date'),0)=TEXT(YEAR('End Date'),0)&TEXT(MONTH('End Date'),0),-1,DATEDIF(EOMONTH('Start Date',0)+1,EOMONTH('End Date',-1)+1,"M"))+(DATEDIF('Start Date',EOMONTH('Start Date',0),"D")+1)/DAY(EOMONTH('Start Date',0))+(DATEDIF(EOMONTH('End Date',-1),'End Date',"D"))/DAY(EOMONTH('End Date',0)),2)

    I know that it looks wordy but I store it in a most used functions worksheet so I can copy it into my worksheet.

    Below is sample of what it answers

    Start Date End Date Real Months
    1/1/2017 12/31/2017 12.00
    1/1/2017 1/2/2017 0.06
    1/5/2017 12/31/2021 59.87
    1/1/2017 2/28/2020 37.97
    1/1/2017 2/29/2020 38.00
    3/15/2017 3/14/2018 12.00
    1/5/2017 11/5/2017 10.04
    3/15/2017 11/5/2017 7.72
    3/1/2018 2/28/2019 12.00
    3/1/2018 2/29/2020 24.00
    3/1/2018 2/28/2020 23.97

    I have not found a bug is my most recent version of this function.

  20. Hi,

    Suppose we need to calculate Date of Retirement using available Date of Births of Employees. How to write a single formula for calculating Retirement Date which should be calculated depending following three conditions - If Public Sector Employee then Retirement Age should be 60 yrs, If Private Sector Employee the Retire Age should be 58 yrs and for Pensioners should be 70 yrs

    Thanks

  21. Hii

    I have needed a formulla, if a employee is joining date and leaving date would be >4 years and 6 months then he will get 50% bonus otherwise he will not eligible.
    please help me.

    1. I need exactly the same calculation. Have been using =datedif(a1,today()"m")>=6, however it is not the TODAY as reference but another date on the spreadsheet.
      so i have got date 1, date 2, and I need to highlight date 2 only if it is over 6 months older than date 1 if that makes sense.

  22. dateif doesn't exists

    1. Hi Alex,

      Dateif doesn't exist, but DateDif does :) However, DATEDIF in an undocumented function, which is why it does not appear in the list of formulas, so you will have to type a whole formula manually.

      1. YAS! thank you - dateif didn't work for me, but datedif did. thank you :-)

  23. Hi,
    I am using Excel 2010 and am trying to work out a formula to work out the difference between two dates
    Could you please help?
    Thank you

    1. =DATEDIF(B2,C2+1,"d")
      Please try this one. In B2 start date & in c2 end date.

      1. I see you add the +1 in the formula. I was wondering about this. I have accounted for this in the past, but everything shows that the number of actual days is apparently one less. Example: 01-NOV-2017 and 30-NOV-2017, no matter what function you use, the answer comes up 29 days instead of 30.

        I usually add the +1 at the end of the formula, but it should come out the same.

        It seems like the functions do not take into account the first day as if you really didn't meant to count it.

  24. Hi
    I would like to know some questions the following case.?
    I have start date and end date for some contracts.
    I used these formula.
    =DATEDIF("Start Date", "End Date", "d")

    I also need to know remaining date (start from open the file date)
    So, I used these formula
    =DATEDIF(TODAY(), "5/20/2015", "d")

    But, Contract start date aren't start when i open the day. So.. it is problem for me.Please tell me how to solve these formula?
    i hope you answer to me.
    Thanks & Best Regards,
    Wint Wah

  25. These formulas are not working in my PC, I am using Excel 2013, and already checked all formulas are correct, surprised to see the error #value

    1. Check the date format. This has to be MM/DD/YYYY

  26. Hi,
    Need a help. I want to calculate the no. of days between two dates by considering that only "sunday" is weekly off & rest 6 days are working.

    Pl advice.

    1. I need a formula that gives me the number of days weeks and months between two dates. (Excluding weekends)
      I am trying to calculate the value of a rental tool per day week and month. Given the following rates : per day $10 per week $40 and month $150
      Thank you!

  27. Great instructions! on negative dates code for between two dates! Best on the web.:) Thank you!

  28. Hi I am trying to automatically get column names in excel basis start date and duration as input. For example if I fill start date as 1-Jan-16 and Duration as 3 years or 36months it should automatically populate columns like Jan-16, Feb-16, Mar-16 .......Dec-18.

  29. I need between date different by this below format

    Start Date 19.02.1989
    End Date 01.02.2017

    1. By right click,format cells,custom,scroll and pick up mm/dd/yyyy and modify it as per ur requirement.

  30. how to find the difference in dates in months so that lets say employees joining before 15th of the month are considered to be working for 1 extra month and employees joining after 15th are not considered? Is it feasible?

  31. How to calculate number of days for the below dates
    09/04/2017 12:50 20/04/2017 11:55

    and as soon as the date cross the time of the start date, one day should be added, how to do it?

  32. Dear,

    Really, it is very help full because sometimes if we don't get in touch with these formulation, can be washed from brain.

  33. Hello Svetlana, Good day

    I'm trying to calculate date difference is days, hours and minutes so there are 2 dates start and end date. Start Date (Date Value) and End Date (Blank or have formula). Any support would be greatly appreciated.

  34. How Two or Five Period of Years, Month, Day Example:
    01 September 1994 31 October 1994 0Years, 1Months, 30days
    04 September 1995 30 November 1995 0Years, 2Months, 26days
    01 December 1995 30 May 1996 0Years, 5Months, 29days

    Total: ______ _______ _____

  35. hello
    I'm trying to figure out, how to calculate no. days between two dates for a particular product which is repeating at different dates.

    plz help me out..
    thanks.

  36. Hi, I'm trying to find a formula calculating days that has passed since..
    For instance, how many days have passed (aged) since date of entry. This will be updated based on an input calendar date.

    Is this possible?

  37. Hello,
    I need to create an elapsed days formula from a start date to today's date for submittals. When the submittal is returned I would like the formula to show elapsed days from the start date to the end date (received) and not today's date.
    Kind regards.

  38. Hi,

    How can I calculate together month and year in excel macro?.

    e.g.
    01-Jan-2017 (Textbox 1)
    01-Feb-2017 (TextBox 2)
    Result: 0.1 (Textbox 3)

    Thank you in advance.

  39. Hi, good day.

    I have a problem to calculate my rental in different period and rate.
    Eg.
    1st - 7th year : 14.09.09 - 13.09.16
    8th - 10th year: 14.09.16 - 13.09.19

    1st - 7th year : $1,000
    8th - 10th year: $750

    1st - 7th year : Splitting percentage 20%
    8th - 10th year: Splitting percentage 50%

    How to converting the above in If formula in excel?

  40. Hi, good day.

    I need help in converting the following if-statements in Excel formula:

    1. If A1 and B1(there are formulas in the column that make of them look blank, although the actual cell is not blank) are blank, then C1 is "";
    2. If A1 is not blank and B1(there are formulas in the column that make of them look blank, although the actual cell is not blank) is blank, then C1 is "Pending";
    3. If A1 and B1 are not blank, then C1 is "Completed".

    What formula can I use?

    Thank you in advance.

  41. Hi Deni,

    Try this:

    =DATEDIF(A1,TODAY(),"y") & " Years, " & DATEDIF(A1,TODAY(),"ym") & " Months, " & DATEDIF(A1,TODAY(),"md") & " Days"

  42. Hi Rach,

    Try this:

    =IF(A1"",DATEDIF(A1,TODAY(),"d"),"")

  43. Hi, I would like to know the Beginning Week Number and Ending Week Number of the month. Thank you.

    1. Unsure if your comment is aimed at me however I am using a start date in one column and an end date in another column. Dates starting are usually the 1st of the month and end dates are normally the last day of the month....

  44. I have just used the DATEDIF formula for Years, Months and Days. I would now like to round these figures up i.e. 14 years 30 Days = 14 years 1 Month/8 years 4 months and 30 days = 8 years and 5 months. Is there an easy way to do that or should I just revert to the DATEDIF formula for Years and Months? Many thanks.

  45. Hello there, I have a question. I have tried to read all posts but it's hard to know which formula I need. I have a birthdate and as of today I can figure out the exact age by year, month and day. Now, I need to know in 3 weeks from now by a specific date how old the pet will be. For instance, the birthday is 11/24/06 so I know from today how old the pet is. But now I need to know for future dates of 02/16/17, 03/15/17 and 04/20/17 exactly how old on those dates the pet will be. I have lined up the dates in the row but I keep getting errors when I try and create a formula from the birthdate...help?

  46. Hi requested support. i want to calculate the number of days after close of month. if their is any support methodology for this query. Please support.

  47. When I try and perform a sort based on results from this formula, it does not sort correctly. Same thing happens if I use a simple =B2-A2 equation. It looks like Excel is returning a number (as opposed to a date). Any clue why it won't sort? Any ideas for a solution?? :-)

    Thanks in advance!!!!

  48. D1 to D100 is the due date and I need column E to give the number of days past due date - PLEASE HELP!!

  49. D1 to D100 is the due date and I need column E to give the number of says past due date - PLEASE HELP!!

  50. Hi there, really struggling with this...
    I am trying to determine the number of nights per week that someone has stayed in accommodation based on their check in (Ci) and check out (Co) dates compared to the week start (Ws) date and week end (We) date.
    Brackets are the named columns / rows.
    Would really appreciate your help on this as would save a lot of manual entry time!
    Many thanks
    Matt

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)