In excel formula for dates

Add or subtract days from a date

Suppose that a bill of yours is due on the second Friday of each month. You want to transfer funds to your checking account so that those funds arrive 15 calendar days before that date, so you’ll subtract 15 days from the due date. In the following example, you’ll see how to add and subtract dates by entering positive or negative numbers. 

Add or subtract days from a date with =A2+B2, where A2 is a date, and B2 is the number of days to add or subtract.

  1. Enter your due dates in column A.

  2. Enter the number of days to add or subtract in column B. You can enter a negative number to subtract days from your start date, and a positive number to add to your date.

  3. In cell C2, enter =A2+B2, and copy down as needed.

Add or subtract months from a date with the EDATE function

You can use the EDATE function to quickly add or subtract months from a date.

The EDATE function requires two arguments: the start date and the number of months that you want to add or subtract. To subtract months, enter a negative number as the second argument. For example, =EDATE(«9/15/19»,-5) returns 4/15/19.

Use EDATE to add or subtract months from a date. In this case, =EDATE(A2,B2) where A2 is a date, and B2 has the number of months to add or subtract.

  1. For this example, you can enter your starting dates in column A.

  2. Enter the number of months to add or subtract in column B. To indicate if a month should be subtracted, you can enter a minus sign (-) before the number (e.g. -1).

  3. Enter =EDATE(A2,B2) in cell C2, and copy down as needed.

    Notes: 

    • Depending on the format of the cells that contain the formulas that you entered, Excel might display the results as serial numbers. For example, 8-Feb-2019 might be displayed as 43504.

    • Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2010 is serial number 40179 because it is 40,178 days after January 1, 1900.

    • If your results appear as serial numbers, select the cells in question and continue with the following steps:

      • Press Ctrl+1 to launch the Format Cells dialog, and click the Number tab.

      • Under Category, click Date, select the date format you want, and then click OK. The value in each of the cells should appear as a date instead of a serial number.

Add or subtract years from a date

In this example, we’re adding and subtracting years from a starting date with the following formula:

=DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2))

Add or subtract years from a starting date with =DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2))

How the formula works:

  • The YEAR function looks at the date in cell A2, and returns 2019. It then adds 3 years from cell B2, resulting in 2022.

  • The MONTH and DAY functions only return the original values from cell A2, but the DATE function requires them.

  • Finally, the DATE function then combines these three values into a date that’s 3 years in the future — 02/08/22.

Add or subtract a combination of days, months, and years to/from a date

In this example, we’re adding and subtracting years, months and days from a starting date with the following formula:

=DATE(YEAR(A2)+B2,MONTH(A2)+C2,DAY(A2)+D2)

Use the DATE function to add or subtract years, months, or days to/from a date.

How the formula works:

  • The YEAR function looks at the date in cell A2, and returns 2019. It then adds 1 year from cell B2, resulting in 2020.

  • The MONTH function returns 6, then adds 7 to it from cell C2. This gets interesting, because 6 + 7 = 13, which is 1-year and 1-month. In this case, the formula will recognize that and automatically add another year to the result, bumping it from 2020 to 2021.

  • The DAY function returns 8, and adds 15 to it. This will work similarly to the MONTH portion of the formula if you go over the number of days in a given month.

  • The DATE function then combines these three values into a date that is 1 year, 7 months, and 15 days in the future — 01/23/21.

Here are some ways you could use a formula or worksheet functions that work with dates to do things like, finding the impact to a project’s schedule if you add two weeks, or time needed to complete a task.

Let’s say your account has a 30-day billing cycle, and you want to have the funds in your account 15 days before the March 2013 billing date. Here’s how you would do that, using a formula or function to work with dates.

  1. In cell A1, type 2/8/13.

  2. In cell B1, type =A1-15.

  3. In cell C1, type =A1+30.

  4. In cell D1, type =C1-15.

    cakculate date

Add months to a date

We’ll use the EDATE function and you’ll need the start date and the number of months you want to add. Here’s how to add 16 months to 10/24/13:

use EDATE formula to add months to a date

  1. In cell A1, type 10/24/13.

  2. In cell B1, type =EDATE(A1,16).

  3. To format your results as dates, select cell B1. Click the arrow next to Number Format, > Short Date.

Subtract months from a date

We’ll use the same EDATE function to subtract months from a date.

Type a date in Cell A1 and in cell B1, type the formula =EDATE(4/15/2013,-5).

Subtract months from a date

Here, we’re specifying the value of the start date entering a date enclosed in quotation marks.

You can also just refer to a cell that contains a date value or by using the formula =EDATE(A1,-5)for the same result.

More examples

To add years to or subtract years from a date

Adding and subtracting dates examples

Start Date

Years added or subtracted

Formula

Result

10/24/2013

3 (add 3 years)

=DATE(YEAR(A2)+B2,MONTH(A2),DAY(A2))

10/24/2016

10/24/2013

-5 (subtract 5 years)

=DATE(YEAR(A4)+B4,MONTH(A4),DAY(A4))

10/24/2008

For work with dates in Excel, in the category «Date and time» is defined in the functions section. Let`s consider the most prevalent functions in this category.



How Excel Processes Time

The Excel program «perceives» the date and time as an ordinary number. The spreadsheet converts to such number, equating the day to unity. As a result, the time value represents a fraction of unity. For example, 12. 00 — is 0. 5.

The date value to the spreadsheet converts to a number which equal to the number of days from January 1, 1900 (so the developers decided) to the specified date. For example, when converting the date 13. 04. 1987, the number is 31880. That is, from 1. 01. 1900 passed 31. 880 days.

This principle underlies in the basis of the calculations of the time data. To find the number of days between two dates, it`s enough to take an earlier period from a later time one.



The example of DATE function

You need to describe of the date value with compiling it with individual elements of numbers.

There is the syntax: year; month, day.

All arguments are required. They can be specified by numbers or by reference to cells with the corresponding numeric data: for the year — from 1900 to 9999; for the month — from 1 to 12; for the day — from 1 to 31.

If you point a larger number for the «Day» argument (than the number of days in the pointed month), you receive the extra days, will be passed to the next month. For example, specifying 32 days for December, we will receive as a result on January 1.

The example of using the function:

example.

Let’s set more days for June:

days June.

Examples of using the cell references as arguments:

cell references as arguments.

The DATEDIF function in Excel

It returns the difference between two dates.

The arguments:

  • start date;
  • final date;
  • the code indicating to the units of counting (days, months, years, etc.).

The methods of measuring intervals between the given dates:

  • to display the result in days — «d»;
  • in months – «m»;
  • in years – «y»;
  • in months without years – «ym»;
  • in days without months and years – «md»;
  • in days without years – «yd».

In some versions of Excel, if you use the last two arguments («md», «yd»), the function may give an error. It is better to use to alternative formulas.

The examples of the operation the DATEDIF function:

DATEDIF.

In Excel 2007 version, this function is not in the directory, but it works. But you need to check the results are better, because there are flaws possible.

The YEAR function in Excel

It returns the year as an integer number (from 1900 to 9999), what corresponds to the specified date. There is only one argument must be entered in the structure of the function – is the date in a numerical format. The argument must be entered using the DATE function or represents to the result of evaluating other formulas.

The example of using the YEAR function:

YEAR.

The MONTH function in Excel: the example

It returns the month as an integer number (from 1 to 12) for a date is specified in a numeric format. The argument – is the date of the month that you want to show in a numerical format. The dates in the text format this function does not handle correctly.

The examples of using the MONTH function:

MONTH.

The examples of DAY, WEEKDAY and functions WEEKNUM in Excel

It returns the day as an integer number (from 1 to 31) for a date specified in a numeric format. The argument – it is the date of the day you want to find in a numerical format.

DAY.

For returning of the weekday ordinal of the specified date, you can apply the function WEEKDAY:

WEEKDAY.

By default, the function considers Sunday the 1-st day of the week.

To display of the ordinal number of the week for the pointed date, you should use the WEEKNUM function:

WEEKNUM.

The date of 24. 05. 2015 is 22 week in a year. The week starts on Sunday (by default).

week starts.

As the second argument the figure 2 is specified. Therefore, the formula considers that the week starts on Monday (the 2-d day of the week).

Download all examples functions for working with dates

For indicating of the current date, the function TODAY (no arguments) is used. To display the current time and date, the function NOW() is used.

The DATE function creates a date using individual year, month, and day arguments. Each argument is provided as a number, and the result is a serial number that represents a valid Excel date. Apply a date number format to display the output from the DATE function as a date.

In general, the DATE function is the safest way to create a date in an Excel formula, because year, month, and day values are numeric and unambiguous, in contrast to text representations of dates which can be misinterpreted. 

Note: to move an existing date forward or backward in time, see the EDATE and EOMONTH.

Example #1 — hard-coded numbers

For example, you can use the DATE function to create the dates January 1, 1999, and June 1, 2010 with the following syntax:

=DATE(1999,1,1) // returns Jan 1, 1999
=DATE(2010,6,1) // returns Jun 1, 2010

Example #2 — cell reference

The DATE function is useful for assembling dates that need to change dynamically based on other inputs in a worksheet. For example, with 2018 in cell A1, the formula below returns the date April 15, 2018:

=DATE(A1,4,15) // Apr 15, 2018

If A1 is then changed to 2019, the DATE function will return a date for April 15, 2019.

Example #3 — with SUMIFS, COUNTIFS

The DATE function can be used to supply dates as inputs to other functions like SUMIFS or COUNTIFS, since you can easily assemble a date using year, month, and day values that come from a cell reference or formula result. For example, to count dates greater than January 1, 2019 in a worksheet where A1, B1, and C1 contain year, month, and day values (respectively), you can use a formula like this:

=COUNTIF(range,">"&DATE(A1,B1,C1))

The result of COUNTIF will update dynamically when A1, B1, or C1 are changed.

Example #4 — first day of current year

To return the first day of the current year, you can use the DATE function like this:

=DATE(YEAR(TODAY()),1,1) // first of year

This is an example of nesting. The TODAY function returns the current date to the YEAR function. The YEAR function extracts the year and returns the result to the DATE function as the year argument. The month and day arguments are hard-coded as 1. The result is the first day of the current year, a date like «January 1, 2021».

Note: the DATE function actually returns a serial number and not a formatted date. In Excel’s date system, dates are serial numbers. January 1, 1900 is number 1 and later dates are larger numbers. To display date values in a human-readable date format, apply the number format of your choice.

Notes

  • The DATE function returns a serial number that corresponds to an Excel date.
  • Excel dates begin in the year 1900. If year is between zero and 1900, Excel will add 1900.
  • The DATE function accepts numeric input only and will return #VALUE if given text.

There are many functions in Microsoft Excel that may be used to work with dates and timings in Excel. Each function completes a straightforward task, but by combining numerous functions into a single formula, you may handle trickier and more complicated problems. The purpose of discussing DATE functions in Excel is to help different people to perform more complex and challenging tasks by combining several functions within one formula.

The DATE function is used to calculate dates in Excel. Excel provides different functions to work with dates & times such as TODAY, NOW, WEEKDAY, EOMONTH, etc. which we will discuss here with examples.

1. DATE Function in Excel

It will return the date in serial number based on the year, month, or day value as provided.

Syntax:

DATE(year,month,day)

Arguments:

  1. Year – This argument includes – 1 to 4-digit values. Excel understands this ‘year’ argument according to the date system of the local computer which we use. For example- Excel windows uses the 1900 date system by default which means DATE (21,2,6) gives the result as 06-02-1921.
  2. Month – This argument includes a positive or negative integer that represents the month of the year from January to December.
  3. Day – This argument also includes a positive or negative integer representing the day of the month from 1 to 31.

Excel Date Function Example 1:

Date Function Example

Excel Date Function Example 2:

 It will return on the first day of the current year & month.

Excel Date Function

Excel Date Function Example 3:

DATE formula in Excel

2. TODAY Function in Excel

The TODAY() function name suggests it will return today’s date, and it has no arguments.

Syntax: 

TODAY()

Example1: 

Here we will print the current date and also add 10 days to the current date.

TODAY Function Example

Example 2: 

To add 10 days to Today’s date.

TODAY Function Excel

3. NOW Function in Excel

This function returns the current date as well as the time & doesn’t have any arguments.

Syntax: 

NOW()

Example:

NOW Function Example

 4. DATEVALUE Function

It converts the date in text format to a serial number, which can be represented as a date.

Syntax: 

DATEVALUE(date_text)

Arguments:

1. date_text – This argument is a text that represents the date in Excel date format.

Example:

DATEVALUE Function Example

5. TEXT Function

It converts any numeric value not only dates to a text string. Through this function, we can change the date to text strings in a variety of formats.

Syntax: 

TEXT(value,format_text)

Arguments: 

1. value: The value that is to be converted.

2. format_text: The format in which you want to output the date value.

These are the different formats used in the TEXT function to change dates to text strings.

Example 1: 

TEXT Function Example

Example 2:

TEXT Function in Excel

Example 3:

Excel TEXT Function Example

6. DAY Function

It returns the day of a month, i.e. integer from 1 to 31.

Syntax: 

DAY(serial_number)

Arguments:

1. serial_number: This value represents the day of the month you want to find. E.g: 5th day of June

Example 1:

DAY Function Example

Example 2:

DAY Function Example Excel

The DAY(TODAY()) function returns the day of today’s date, as shown below:

 day of today's date excel

7. MONTH Function

This function returns the month of the given date as an integer from 1 to 12 (January to December).

Syntax: 

MONTH(serial_number)

Arguments: 

1. serial_number: This value represents the date for which you want to find the month.

Example:

MONTH Function Example

The MONTH(TODAY()) function returns the month of today’s date.

function to return month of today's date

8. YEAR Function

It returns the year of a specified date.

Syntax: 

YEAR(serial_number)

Arguments:

1. serial_number: The date to be specified.

Example 1:

YEAR Function Example

Example 2:

YEAR Function Example Excel

Example 3:

YEAR Function in Excel

9. EOMONTH Function

This function returns the last day of the month after adding a specified number of months to a given date.

Syntax: 

EOMONTH(start_date,months)

Arguments:

1. start_date: In this argument, the date should be written in date format, not in the text.

2. months: In this argument, if a positive integer is given then corresponding months can be added to the start date & if a negative integer is given then the corresponding months can be subtracted from the start date.

Example 1:

 EOMONTH Function Example

Example 2:

 EOMONTH Function Example Excel

Example 3:

 EOMONTH Function in Excel

The EOMONTH(TODAY(),0) function returns the last day of the current month.

function to return the last day of the current month

10. WEEKDAY Function

This function returns the day of the week as a number from 1 to 7 (Sunday to Saturday) according to the specified date.

Syntax: 

WEEKDAY(serial_number,return_type)

Arguments:

1. serial_number: It can be a date or the cell that contains the date.

2. return_type: It is optional, as it specifies which day should be considered as the first day of the week.

NOTE: 1st day of the week is by default Sunday.

Example 1:

WEEKDAY Function Example

Example 2: 

In the below example, 2 is given as return_type i.e. Monday is referred to as the first day of the week.

Excel WEEKDAY Function Example

Example 3:

Here the day of today’s (01-04-2021) date is the result & the default value (Sunday) is considered here because no return_type is given.

WEEKDAY Function in Excel

11. DATEDIF Function

This function calculates the difference between two dates in days, months, or years. For calculating the difference b/w dates which time interval should be used depends on the letter which we specify in our last argument i.e. at the unit.

Syntax: 

DATEDIF(start_date,end_date,unit)

Arguments:

1. start_date: The start date for evaluating the difference.

2. end_date: The end Date for evaluating the difference.

Example 1:

DATEDIF Function Example

Example 2:

Excel DATEDIF Function Example

Example 3:

DATEDIF Function in Excel

Here “m”,”y”,”d” means month, year & date. In the first example, the difference between dates is calculated by months, second by year & third by date.

12. WEEKNUM Function

It returns the week number based on the specified date, i.e. from 1 to 52 weeks of the year.

Syntax: 

WEEKNUM(serial_number,firstday_ofweek)

Arguments: 

1. serial_number: This is the date for which we want the week number.

2. firstday_ofweek: This is an optional argument that specifies which numbering system should be considered & which day of the week can be treated as the start of the week, Default(omitted) is 1. The table below is the parameters that can be given in firstday_ofweek argument.

First Day of the Week Start Table:

1 Sunday 1
2 Monday 1
11 Monday 1
12 Tuesday 1
13 Wednesday 1
14 Thursday 1
15 Friday 1
16 Saturday 1
17 Sunday 1
21 Monday 2

Example 1:

WEEKNUM Function Example

Example 2:

WEEKNUM Function in Excel

Example 3:

In the below example,21 is given as the second argument which means Monday is taken as the first day of the week & in the above example, the result shown is 15 but taking 21 as the first_dayofweek means Monday is the first day, the result is 14.

WEEKNUM Function Example in Excel

13. EDATE Function

This function adds or subtracts the specified month to a given date.

Syntax: 

EDATE(start_date,months)

Arguments:

1. start_date: This is an initial date on which the months are added or subtracted.

2. months: This is the number of months which is to be added or subtracted in the specified date.

Example 1:

EDATE Function Example 1

Example 2:

EDATE Function Example 2

Example 3:

EDATE Function Example 3

 14. YEARFRAC Function

This function returns the fraction of the year which represents the number of whole days between the start & end date.

Syntax: 

YEARFRAC(start_date,end_date,[basis])

Arguments:

1. start_date: This is the start date in the serial number.

2. end_date: This is the end date in the serial number.

3. basis: This is the optional argument that specifies the day count method.

Basis Day count method
0(default) US 30/360
1 actual/actual
2 actual/360
3 actual/365
4 European 30/360

Example 1: 

Using someday count methods.

YEARFRAC Function Example

Example 2:

YEARFRAC Function in Excel

Example 3:

Excel YEARFRAC Function

15. WORKDAY Function

This function helps if we exactly know how many working days we have & want to find out the date when the number of working will skip. This function always includes working days & excludes weekend days.

Syntax: 

WORKDAY(start_date,days,holidays)

Arguments:

1. start_date: This argument is the date from which the counting of weekdays begins. Excel doesn’t include start_date as a working day.

2. days: This is the number of working days.

3. holidays: This is an optional argument. If the days mentioned include any holidays, then we need to make a list of holidays separately for this, and mention it here.

Example 1: 

28 workdays from the start date, excluding holidays.

WORKDAY Function Example

Example 2: 

28 workdays before the start date, excluding holidays

WORKDAY Function in Excel

Example 3: 

28 workdays from the start date, no holidays.

Excel WORKDAY Function

Example 4: 

28 workdays from today’s date, no holidays.

WORKDAY Function Example in Excel

16. WORKDAY.INTL Function

This is a modification of the WORKDAY function as it provides a custom weekend parameter that distinguishes this from the WORKDAY function.

Syntax: 

WORKDAY.INTL(start_date,days,[weekends],holidays)

Arguments:

1. start_date: This argument is the date from which the counting of weekdays begins. Excel doesn’t include start_date as a working day.

2. days: This is the number of working days.

3. holidays: This is an optional argument. If the days mentioned include any holidays, then we need to make a list of holidays separately for this and mention it here.

4. weekends: Through this argument, we can specify which days of the week to be treated as non-working days, either by weekend number or specific character string.

Weekend Number:

Numbers Days
1 (default) Saturday, Sunday
2 Sunday, Monday
3 Monday, Tuesday
4 Tuesday, Wednesday
5 Wednesday, Thursday
6 Thursday, Friday
7 Friday, Saturday
11 Sunday
12 Monday
13 Tuesday
14 Wednesday
15 Thursday
16 Friday
17 Saturday

If this weekend argument is blank in this function, then it will automatically take the combination of Saturday & Sunday.

For instance:

  • “0000011”-Saturday & Sunday are weekends(non-working days)
  • “1000010”-Monday & Saturday are weekends(non-working days)

Example 1: 

30 days from the start date, excluding holidays & Sunday, and Monday as weekends (by giving weekend number 2 as arguments).

WORKDAY.INTL Function Example

Example 2: 

30 days from the start date, excluding holidays & Sunday, Monday as weekends(by giving weekend string “1000001” as arguments).

WORKDAY.INTL Function in Excel

Example 3: 

20 days from the start date, no holidays & Monday, Saturday as weekends (by giving weekend string “1000010” as arguments).

Excel WORKDAY.INTL Function

17. NETWORKDAYS Function

This function returns the number of working days between two dates, excluding weekends & holidays are as optional arguments.

Syntax: 

NETWORKDAYS(start_date,end_date,holidays)

Arguments:

1. start_date: The initial date to start evaluation.

2. end_date: The last date to end the evaluation.

4. holidays: Used to specify holidays.

Example 1:

NETWORKDAYS Function Example

Example 2:

NETWORKDAYS Function in Excel

18. NETWORKDAYS.INTL Function

This function also returns the number of working days between two dates but provides the additional argument weekend to specify which days should be counted as weekend days.

The structure of the weekend argument is the same as for WORKDAY.INTL i.e. we can use either the weekend number or character string.

Syntax: 

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

Arguments:

1. start_date: The initial date to start the evaluation.

2. end_date: The last date to end the evaluation.

3. weekend: Use to specify the weekends.

4. holidays: Used to specify holidays.

Example 1: 

Here, the weekend argument is given in the form of a number.

NETWORKDAYS.INTL Function Example

Example 2: 

Here, the weekend argument is given in the form of a character string of 0’s & 1’s.

NETWORKDAYS.INTL Function in Excel

Hopefully, this extensive overview of Excel’s date functions has given you a general idea of how date formulas in Excel operate. I advise you to read more articles on Excel if you want to understand more. I appreciate your time and look forward to hearing from you soon!

FAQs on DATE Functions in Excel

Here are some of the most frequently asked questions on DATE Functions in Excel

1. What is a Date function?

The DATE function in Excel combines the three independent values of year, month, and day to create a date.

Syntax: DATE(year,month,day)

2. How do I get DD MMM YYYY in Excel?

  • Pick the cell that contain the date>right-click and select Format Cells
  • Select Custom in the Number Tab>type ‘dd-mmm-yyyy’ in the Type text box>click OK.

Понравилась статья? Поделить с друзьями:
  • In our time written word
  • In excel date format is not changing
  • In a word yes grammar
  • In our days everybody knows what the word america means
  • In excel columns are labelled as