ExcelCSE.com

Menu
  • Excel 101
  • Excel Functions
  • Excel Formula
  • Contact Us
How to Use Excel > Excel Formula > Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel

Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel

Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel
Table of contents :
  • Calculate Number of Days Between Two Dates
  • Calculate Number of Weeks Between Two Dates
  • Calculate Number of Months Between Two Dates
  • Calculate Number of Years Between Two Dates

Calculate Number of Days, Weeks, Months and Years between Two Dates

Calculate Number of Days Between Two Dates

Excel has a function that calculates the number of days between two dates, the DATEDIF function.

Number of Days between Two Dates

The Formula

=DATEDIF(A2,B2,"d")

You got the number of days between two dates, but there is one problem, cell C4 returns an error. Error #NUM! happens because the end date is earlier than the start date.

Please read the article below for a more detailed explanation for DATEDIF function

  • How to use DATEDIF function in Excel

To fix the #NUM! Error, the solution is to use the subtraction formula. Excel stores date values as an integer number, to find out the number of days between two dates use the subtraction formula.

Number of Days between Two Dates

The Formula

=B2-A2

Look at cell C4, the DATEDIF function returns a #NUM error, but with subtraction formula, there is no error but a negative number.

Calculate Number of Weeks Between Two Dates

To calculate the number of weeks between two dates divide the number of days between two dates by number 7. The result is the number of weeks between two dates.

Number of Weeks between Two Dates

The Formula

=(B2-A2)/7

A result is a decimal number, a number of weeks between October 29, 2018, and January 5, 2019, is 9.714286.

Is it possible to get a full week difference and shows the remaining days (that are not up to 1 week)? Of course, Excel can do this, thanks to the QUOTIENT and MOD function.

Number of Weeks between Two Dates

The Formula for weeks column

=QUOTIENT(B2-A2,7)

The Formula for days column

=MOD(B2-A2,7)

Between October 29, 2018, and January 5, 2019, there are nine weeks and five days.

Please read the article below for a more detailed explanation for QUOTIENT and MOD function

  • How to use QUOTIENT function in Excel
  • How to use MOD function in Excel

Calculate Number of Months Between Two Dates

To calculate the number of months between two dates, you must use the DATEDIF function. You cannot use the division formula that divides the number of days between two dates by 30. Why? Because in a month could be 28, 29, 30 or 31 days.

Number of Months between Two Dates

The Formula

=DATEDIF(A2,B2,"m")

You got a #NUM! error, it means the DATEDIF function unable to do a calculation if the end date is earlier than the start date.

The solution is to change the start date and the end date position if the end date is earlier than the start date. You need the IF function to do this trick.

Number of Months between Two Dates

The Formula

=IF(B2<A2,-1*DATEDIF(B2,A2,"m"),DATEDIF(A2,B2,"m"))

No more #NUM errors and cell C4 can display a negative number :).

The DATEDIF function result is a complete difference. If there is less than 1-month days difference, excel will ignore it.

How to calculate the remaining days that are not up to 1 month? still using the DATEDIF function but the unit argument is “md” (calculating the day difference by ignoring the difference in months).

Number of Months between Two Dates

The formula for days column

=IF(B2<A2,-1*DATEDIF(B2,A2,"md"),DATEDIF(A2,B2,"md"))

Calculate Number of Years Between Two Dates

How to calculate number of years, months and days between two dates?

Number of Years between Two Dates

The Formula for years column

=IF(B2<A2,-1*DATEDIF(B2,A2,"y"),DATEDIF(A2,B2,"y"))

The Formula for months column

=IF(B2<A2,-1*DATEDIF(B2,A2,"ym"),DATEDIF(A2,B2,"ym"))

The Formula for days column

=IF(B2<A2,-1*DATEDIF(B2,A2,"md"),DATEDIF(A2,B2,"md"))

Related Function

Function used in this article
  • Excel DATEDIF Function
  • Excel IF Function
  • Excel QUOTIENT Function
  • Excel MOD Function
Usefull links
  • Microsoft Excel Calculate the Different between Two Dates documentation
Share
Tweet
Google+
Email
Prev Article
Next Article

Related Articles

VLOOKUP MATCH
VLOOKUP MATCH – Solution for VLOOKUP REF Error The article …

VLOOKUP MATCH – a Combination for a Solution

How to Merge Cells in Excel without Losing Data
To merge two cells or more without losing data, you …

How to Merge Cells in Excel without Losing Data

VLOOKUP Multiple Criteria
The Solution for Numeric Result For example, there is data …

VLOOKUP Multiple Criteria – Solution for Numeric or Non-Numeric Result

SUMPRODUCT IF
There is no SUMPRODUCTIF function in excel, but you can …

SUMPRODUCT IF – Multiple Criteria SUMPRODUCT

Add time in excel
Excel stores date value in integer number and time value …

How to Add Seconds, Minutes and Hours to a Time in Excel

Tags:Calculate Number of Days Between Dates Calculate Number of Days Between Dates Excel Calculate Number of Days Between Two Dates Calculate Number of Days Between Two Dates in Excel Calculate Number of Days From a Date Calculate Number of Days in Excel Calculate Number of Months Calculate Number of Months Between Two Dates Calculate Number of Months Between Two Dates in Excel Calculate Number of Weeks Between Dates Calculate Number of Weeks Between Two Dates Count Number of Days Between Two Dates Count Number of Days Between Two Dates in Excel DATEDIF Function Excel Number of Weeks Between Two Dates Find Number of Days Between Two Dates How to Calculate Number of Days Between Two Dates How to Calculate Number of Days in Excel IF Function MOD Function Number of Days Between Number of Days Between 2 Dates Number of Days Between Dates Number of Days Between Two Dates Number of Days Between Two Dates Excel Number of Days From Date Number of Months Between Two Dates Number of Months Between Two Dates Excel Number of Months Between Two Dates in Excel Number of Weeks Between Two Dates Number of Weeks Between Two Dates Excel Number of Years Between Two Dates QUOTIENT Function

Categories

  • Excel 101
  • Excel Formula
  • Excel Functions

Recent Posts

  • Get the Original Price from Percentage Increase/Decrease
  • How to Add/Subtract Percentage in Excel
  • How to Extract Day, Month and Year from Date in Excel
  • How to Add Seconds, Minutes and Hours to a Time in Excel
  • How to Add Days, Weeks, Months and Years to a Date in Excel
  • How to Calculate Time Difference in Excel
  • Calculate Number of Days, Weeks, Months and Years Between Two Dates in Excel
  • Flash Fill Excel
  • Paste Special Excel
  • Excel TEXTJOIN Function
  • Excel CONCAT Function
  • Excel CONCATENATE Function
  • Excel REPLACE Function
  • Excel SUBSTITUTE Function
  • Excel REPT Function
  • Excel FIND Function
  • Excel SEARCH Function
  • Excel MID Function
  • Excel RIGHT Function
  • Excel LEFT Function

ExcelCSE.com

The Ultimate Guide How to Use Excel Better
Copyright © 2024 ExcelCSE.com
Contact Us - Privacy Policy - Sitemap | Theme by MyThemeShop.com

Ad Blocker Detected

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Refresh