Calculate date between excel

The date and time in Excel — there are numbers, formatted in a special way. The date is the integer part of the number, and the time (hours and minutes) is the fractional part.

By default, the number 1 corresponds to the date of 01. 01. 1900 — that is, each date — is the number of days passed from 01. 01. 1900. In this lesson, we will take a closer look at the dates, and in the next lessons – the time.



How in Excel to calculate the days between dates?

Since the date is a number, it means that you can conduct mathematical computing and settlement operations. To count the number of days between two Excel dates does not present any special problems. For a visual example, we first perform the addition, and then subtraction of dates. For this:

  1. On a blank sheet in the cell A1 you need to enter the current date by pressing CTRL +.
  2. In the cell A2 you need to enter an intermediate period in days, for example, 127.
  3. In the cell A3 you need to enter the formula: = A1 + A2.

Since the date is a number.

Note that the «Date» format was automatically assigned to the cell A3. It’s not difficult to guess, to calculate the difference in dates in Excel, you need to take away the highest date from the newest date. In the cell B1 you need to enter the formula: A3 — A1. Accordingly, we get the number of days between these two dates.



The calculating age by date of birth in Excel

Now we will learn how to calculate the age by date of birth:

  1. In the new sheet in the cells A1: A3, you need to enter the dates: 18. 04. 1985; 17. 08. 1977; 08. 12. 1992.
  2. In the cells B1 : B3, you need to put the current date.
  3. Now you need to use the function to convert the number of days to the number of years. To do this, you need to enter by manually the following value in the range C1:C3: = DATEDIF(A1; B1; «y»).

calculate the age by date.

Thus, the application of the function allowed us to accurately calculate the age by date of birth in Excel.

Attention! To transform days into years, there is not enough of the formula: Moreover, even if we know that 1 day = 0.0027397260273973 of the year, the formula: =(B1-A1)*0.0027397260273973 will not give us the exact result either.

Days in the years the most accurately to convert the function: = DATEDIF(). You will not find it in the list of the function wizard (SHIFT+F3), but if you simply to enter it into the formula line, it will work.

The DATEDIF function supports to the several parameters:

Option Description
«d» Count of full days;
«m» Count of full months;
«y» Count of full years;
«ym» Count of full months without years;
«md» Count of days without months and years;
«yd» Count of days without years.

Let’s illustrate the example of using several parameters:

using several parameters.

Attention! That the function: = DATEDIF() worked without errors, make sure that the start date was older than the end date.

The insertion of the date in the Excel cell

The purpose of this lesson is an example of mathematical operations with dates. Also, we’ll make sure that for Excel, the date data type is a number.

You need to fill in the table with dates, as shown in the picture:

fill in the table with dates.

There are different ways of entering dates: in the column A there is input method, and in column B there is the display result.

Note that the default format cell is «General», the dates as well as the number are aligned on the right side, and the text on the left one. The value in the cell B4 is recognized by the program as text.

In the cell B7 Excel has assigned by itself to the current year (now is the 2015-th) by default. This is visible when displaying the contents of cells in the formula bar. Notice how the value was originally entered in A7.

The calculating of the Excel date

On the blank sheet in the cells A1 and C1 you need to enter 01. 01. 1900, and in the cells A2 and C2 is 01. 01. 1901. Now we change the format of the cells to «numeric» in the selected range C1:C2. To do this, you can press CTRL + SHIFT + 1.

calculating of Excel date.

C1 contains now the number 1, and C2 — 367. That is, one leap year (366 days) now and one day passed.

The way to display the date can be set using the «Format Cells» dialog box. To call it, press: CTRL + 1. On the «Number» tab, you need to select «Category:» — «Date». In the «Type:» section displays the most popular formats for displaying dates.

display date.

Download examples calculate date in Excel

Read also: The functions for working with dates in Excel

In the next lesson, we will work with the time and the periods of the day on ready-made examples.

The YEARFRAC function returns a decimal number representing the fractional years between two dates. For example:

=YEARFRAC("1-Jan-2019","1-Jan-2020") // returns 1
=YEARFRAC("1-Jan-2019","1-Jul-2020") // returns 1.5

Here are a few examples of the results that YEARFRAC calculates:

Start date End date YEARFRAC result
1/1/2015 1/1/2016 1
3/15/1970 9/15/1976 6.5
1/1/2000 7/15/2000 .5389
6/1/2000 6/25/1999 .9333

In the example shown, the formula in D6 is:

=YEARFRAC(B6,C6) // returns 1

Rounding results

Once you have the decimal value, you can round the number if you like. For example, you could round to the nearest whole number with the ROUND function:

=ROUND(YEARFRAC(A1,B1),0)

Whole years only

You might also want to keep only the integer portion of the result with no fractional value, so that you are only counting whole years. In that case, you can just wrap YEARFRAC in the INT function:

=INT(YEARFRAC(A1,B1))

If you need to calculate years on an ongoing basis, for example to get age based on a birthday, see the example here.

Note: The YEARFRAC function has an optional 3rd argument that controls how days are counted when computing fractional years. The default behavior is to count days between two dates based on a 360-day year, where all 12 months are considered to have 30 days. The YEARFRAC page provides more information.


We can use the DATEDIF() function to calculate the difference between two dates in Excel.

This function uses the following syntax:

=DATEDIF(Start_Date, End_Date, Metric)

where:

  • Start_Date: The start date
  • End_Date: The end date
  • Metric: The metric to calculate. Options include:
    • “d”: Days
    • “m”: Months
    • “y”: Years

It’s important to note that this function won’t automatically appear in Excel until you completely type =DATEDIF( into one of the cells. 

The following examples show how to use this function to calculate the difference between two dates in Excel.

Example 1: Difference in Days

The following image shows how to calculate the difference (in days) between two dates:

Date difference in days in Excel

This tells us that there are 1,127 full days between 1/1/2018 and 2/1/2021.

Example 2: Difference in Months

The following image shows how to calculate the difference (in months) between two dates:

Difference in dates in months in Excel

Example 3: Difference in Years

The following image shows how to calculate the difference (in years) between two dates:

Difference in years between two dates in Excel

Example 4: Difference in Years & Months

The following image shows how to calculate the difference (in years and months) between two dates:

Difference in years and months between two dates in Excel

You can find more Excel tutorials on this page.


This post will teach you how to calculate days, weeks, months and years between two dates in excel. How do I count the number of days, weeks, months and years between 2 dates in excel.

Table of Contents

  • Calculate days between two dates
  • Calculate months between two dates
  • Calculate years between two dates
  • Calculate weeks between two dates
  • Calculate Years, Months and Days between two dates
    • Related Functions

If you want to calculate the difference in days between two dates, you can use the DATEDIF function to create an excel formula as follows:

=DATEIF(B1,B2, "D")

This formula will calculate days between two dates in cell B1 and B2, then returns the value in days.

Calculate months between two dates

If you want to calculate the difference in months between tow dates, you can also use the DATEDIF function to create the following generic formula:

=DATEDIF(B1,B2,"M")

You should note that the third argument is “M” in the DATEDIF function. So this formula returns the value in months between two dates in excel.

Calculate years between two dates

You can also use the DATEDIF function to calculate the number of years between two dates in excel, just refer to the following excel formula based on the DATEDIF function:

=DATEDIF(B1,B2,"Y")

This formula returns the value in years.

Calculate weeks between two dates

If you want to calculate the number of weeks between two dates, you just need to subtract start date from the end date and then the returned result is divided by 7. So you can write the below generic formula:

=(B2-B1)/7

calculate days weeks months between two dates1

This formula will return a decimal number, you can change the number format as you need.

Or you can use the INT function to rounds down to the nearest whole number or use ROUND function to round to nearest whole number.

=INT((B2-B1)/7)

calculate days weeks months between two dates2

=ROUND((B2-B1)/7,0)

calculate days weeks months between two dates3

You may be want to display the word “week” before the week number in the cell, you can do it as following steps:

1# right-click on the selected cells, then select Format Cells

2# on the Number Tab, choose Custom under Category, then select # “weeks” type.

calculate days weeks months between two dates4

calculate days weeks months between two dates5

Calculate Years, Months and Days between two dates

If you want to determine how many years, months and days between two dates, you can use the DATEDIF function to create the following complex formula:

=DATEDIF(B1,B2,"Y") & " Years, " & DATEDIF(B1,B2,"YM") & " Months, " & DATEDIF(B1,B2,"MD") & " Days"

If you do not want to use the DATEDIF function, and you can also use the following formula to achieve the same result:

=INT((TODAY()-A1)/365.25) & ” years , ” & INT(MOD((TODAY()-A1)/365.25,1)*12) & ” months and ” & INT(MOD((TODAY()-A1)/30.4375,1)*30.4375) & ” days”

  • Excel INT function
    The Excel INT function returns the integer portion of a given number. And it will rounds a given number down to the nearest integer.The syntax of the INT function is as below:= INT (number)…
  • Excel DATEDIF function
    The Excel DATEDIF function returns the number of days, months, or years between tow dates.The syntax of the DATEDIF function is as below:=DATEDIF (start_date,end_date,unit)…
  • Excel TODAY function
    The Excel TODAY function returns the serial number of the current date. So you can get the current system date from the TODAY function. The syntax of the TODAY function is as below:=TODAY()…
  • Excel Round function
    The Excel INT function rounds a number to a specified number of digits. You can use the ROUND function to round to the left or right of the decimal point in Excel.The syntax of the ROUND function is as below:=ROUND (number, num_digits)…

Watch Video – Calculate the Number of Workdays Between Two Dates

Excel has some powerful functions to calculate the number of days between two dates in Excel. These are especially useful when you’re creating Gantt charts or timelines for a proposal/project.

In this tutorial, you’ll learn how to calculate the number of days between two dates (in various scenarios):

Calculating the Total Number of Days Between Two Dates in Excel

Excel has multiple ways to calculate the days between two dates.

Using the DAYS Function

Excel DAYS function can be used to calculate the total number of days when you have the start and the end date.

You need to specify the ‘Start Date’ and the ‘End Date’ in the Days function, and it will give you the total number of days between the two specified dates.

For example, suppose you have the start date is in cell B1 and End Date is in cell B2 (as shown below):

Start date and end date in Excel

The following formula will give you the total number of days between the two dates:

=DAYS(B2,B1)

DAYS Formula to get the Number of Days

Note that you can also manually specify the dates in the Days function by putting it in double-quotes. Just make sure these dates in double-quotes is in an accepted date format in Excel.

Days function gives you the number of days between two dates. This means that if the dates are 1 Dec 2017 and 2 Dec 2017, it will return 1. If you want both the days to be counted, you need to add 1 to the result of Days function. You can read more about the Days function here.

Using the DATEDIF Function

DATEDIF function (derived from Date Difference) also allows you to quickly get the number of days between two dates. But unlike the DAYS function, it can do more than that.

You can also use the DATEDIF function to calculate the number of months or years that have elapsed in the two given dates.

Suppose you have the below dataset and you want to get the number of days between these two dates:

Start date and end date in Excel

You can use the below DATEDIF formula to do this:

=DATEDIF(B1,B2,"D")

The above DATEDIF formula takes three arguments:

  • The start date – B1 in this example
  • The end date – B2 in this example
  • “D” – the text string that tells the DATEDIF function what needs to be calculated.

Also note that unline the other Excel functions, when you type the DATEDIF function in Excel, it will not show the IntelliSense (the autocomplete option that helps you with the formula arguments).

If you only want to calculate the number of days between two given dates, then it’s better to use the DAYS function. DATEDIF is more suited when you want to calculate the total number of years or months that have passed in between two dates.

For example, the below formula would give you the total number of months between the two dates (in B1 and B2)

=DATEDIF(B1,B2,"M")

Similarly, the below formula will give you the total number of years between the two dates:

=DATEDIF(B1,B2,"Y")

You can read more about the DATEDIF function here. One of the common uses of this function is when you need to calculate age in Excel.

Number of Working Days Between Two Dates in Excel

Excel has two functions that will give you the total number of working days between two dates and will automatically account for weekends and specified holidays.

  • Excel NETWORKDAYS function – you should use this when the weekend days are Saturday and Sunday.
  • Excel NETWORKDAYS INTERNATIONAL function – use this when the weekend days are not Saturday and Sunday.

Let’s first quickly have a look at NETWORKDAYS Function syntax and arguments.

Excel NETWORKDAYS Function – Syntax & Arguments

=NETWORKDAYS(start_date, end_date, [holidays])

  • start_date – a date value that represents the start date.
  • end_date – a date value that represents the end date.
  • [holidays] – (Optional) It is a range of dates that are excluded from the calculation. For example, these could be national/public holidays. This could be entered as a reference to a range of cells that contains the dates, an array of serial numbers that represent the dates, or a named range.

Let’s first look at an example where you want to calculate the number of working days (business days) between two dates with Saturday and Sunday as weekends.

Dates data set where days needs to be calculated between two dates

To calculate the number of working days (Column D) – when the start date, end date, and holidays are specified – use the below formula in D3 and copy for all cells:

=NETWORKDAYS(B2,C2,$F$2:$F$6)

networkdays formula result

This function works great in most cases, except the ones where the weekends are days other than Saturday and Sunday.

For example, in middle-eastern countries, the weekend is Friday and Saturday, or in some jobs, people may have a six-day workweek.

To tackle such cases, Excel has another function – NETWORKDAYS.INTL (introduced in Excel 2010).

Before I take you through the example, let’s quickly learn about the syntax and arguments of Excel NETWORKDAY INTERNATIONAL function

Excel NETWORKDAYS INTERNATIONAL Function – Syntax & Arguments

=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])

  • start_date – a date value that represents the start date.
  • end_date – a date value that represents the end date.
  • [weekend] – (Optional) Here, you can specify the weekend, which could be any two days or any single day. If this is omitted, Saturday and Sunday are taken as the weekend.Networkdays International formula syntax and weekend options
  • [holidays] – (Optional) It is a range of dates that are excluded from the calculations. For example, these could be national/public holidays. This could be entered as a reference to a range of cells that contains the dates or could be an array of serial numbers that represent the dates.

Now let’s see an example of calculating the number of working days between two dates where the weekend days are Friday and Saturday.

Suppose you have a dataset as shown below:

networkdays function

To calculate the number of working days (Column D) with the weekend as Friday and Saturday, use the following formula:

=NETWORKDAYS.INTL(B2,C2,7,$F$2:$F$6)

The third argument in this formula (the number 7) tells the formula to consider Friday and Saturday as the weekend.

networkdays intl formula result

Number of Weekends Between Two Dates in Excel

We can use the NETWORKDAYS function to calculate the number of weekends between two dates.

While the Networkdays function calculates the number of working days, we can also use to get the number of weekend days between two dates.

Suppose we have a dataset as shown below:

Dataset to calculate the number of weekend days in Excel

Here is the formula that will give you the total number of weekends days between the two dates:

=DAYS(C2,B2)+1-NETWORKDAYS(B2,C2)

weekend formula - to give the number of weekend days between two dates

Number of Work Days in a Part-time Job

You can use Excel NETWORKDAYS.INTL function to calculate the number of workdays in a part-time job as well.

Let’s take an example where you are involved in a project where you have to work part-time (Tuesday and Thursday only).

Calculate part time working days in Excel - Dataset

Here is the formula that will get this done:

=NETWORKDAYS.INTL($B$3,$C$3,"1010111",$E$3:$E$7)

NETWORKDAYS International formula to get the part time working days

Note that instead of choosing the weekend from the drop-down that’s inbuilt in the function, we have used “1010111” (in double quotes).

  • 0 indicates a working day
  • 1 indicates a non-working day

The first number of this series represents Monday and the last number represents Sunday.

So “0000011 would mean that Monday to Friday are working days and Saturday and Sunday are non-working (weekend).

With the same logic, “1010111” indicates that only Tuesday and Thursday are working, and rest 5 days are non-working.

In case you have holidays (which you don’t want to get counted in the result), you can specify these holidays as the fourth argument.

Number of Mondays Between Two Dates

To find the number of Mondays between two dates (or any other day), we can use the same logic as used above in calculating part-time jobs.

Suppose you have a dataset as shown below:

Start date and end date to get the number of Mondays

Here is the formula that will give you the number of Mondays between the two dates:

=NETWORKDAYS.INTL(B2,C2,"0111111")

Using Networkdays INTL function to get the number of Mondays

In this formula, ‘0’ means a working day and ‘1’ means a non-working day.

This formula gives us the total number of working days considering that Monday is the only working day of the week.

Similarly, you can also calculate the number of any day between two given dates.

You May Also Like the Following Tutorials:

  • Excel Timesheet Calculator Template.
  • Convert Date to Text in Excel.
  • How to Group Dates in Pivot Tables in Excel.
  • How to Automatically Insert Date and Time Stamp in Excel.
  • Convert Time to Decimal Number in Excel (Hours, Minutes, Seconds)
  • How to SUM values between two dates in Excel
  • Get Day Name from Date in Excel
  • Check IF a Date is Between Two Given Dates in Excel
  • How to Add Week to Date in Excel?

Понравилась статья? Поделить с друзьями:
  • Calculate all formulas in excel
  • Calculate all cells in excel
  • Calcium and hydrochloric acid word equation
  • Calc интерфейс как excel
  • Cagr формула расчета в excel на русском