Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less
Use Excel’s DATE function when you need to take three separate values and combine them to form a date.
The DATE function returns the sequential serial number that represents a particular date.
Syntax: DATE(year,month,day)
The DATE function syntax has the following arguments:
-
Year Required. The value of the year argument can include one to four digits. Excel interprets the year argument according to the date system your computer is using. By default, Microsoft Excel for Windows uses the 1900 date system, which means the first date is January 1, 1900.
Tip: Use four digits for the year argument to prevent unwanted results. For example, «07» could mean «1907» or «2007.» Four digit years prevent confusion.
-
If year is between 0 (zero) and 1899 (inclusive), Excel adds that value to 1900 to calculate the year. For example, DATE(108,1,2) returns January 2, 2008 (1900+108).
-
If year is between 1900 and 9999 (inclusive), Excel uses that value as the year. For example, DATE(2008,1,2) returns January 2, 2008.
-
If year is less than 0 or is 10000 or greater, Excel returns the #NUM! error value.
-
-
Month Required. A positive or negative integer representing the month of the year from 1 to 12 (January to December).
-
If month is greater than 12, month adds that number of months to the first month in the year specified. For example, DATE(2008,14,2) returns the serial number representing February 2, 2009.
-
If month is less than 1, month subtracts the magnitude of that number of months, plus 1, from the first month in the year specified. For example, DATE(2008,-3,2) returns the serial number representing September 2, 2007.
-
-
Day Required. A positive or negative integer representing the day of the month from 1 to 31.
-
If day is greater than the number of days in the month specified, day adds that number of days to the first day in the month. For example, DATE(2008,1,35) returns the serial number representing February 4, 2008.
-
If day is less than 1, day subtracts the magnitude that number of days, plus one, from the first day of the month specified. For example, DATE(2008,1,-15) returns the serial number representing December 16, 2007.
-
Note: Excel stores dates as sequential serial numbers so that they can be used in calculations. January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900. You will need to change the number format (Format Cells) in order to display a proper date.
Syntax: DATE(year,month,day)
For example: =DATE(C2,A2,B2) combines the year from cell C2, the month from cell A2, and the day from cell B2 and puts them into one cell as a date. The example below shows the final result in cell D2.
Need to insert dates without a formula? No problem. You can insert the current date and time in a cell, or you can insert a date that gets updated. You can also fill data automatically in worksheet cells.
-
Right-click the cell(s) you want to change. On a Mac, Ctrl-click the cells.
-
On the Home tab click Format > Format Cells or press Ctrl+1 (Command+1 on a Mac).
-
3. Choose the Locale (location) and Date format you want.
-
For more information on formatting dates, see Format a date the way you want.
You can use the DATE function to create a date that is based on another cell’s date. For example, you can use the YEAR, MONTH, and DAY functions to create an anniversary date that’s based on another cell. Let’s say an employee’s first day at work is 10/1/2016; the DATE function can be used to establish his fifth year anniversary date:
-
The DATE function creates a date.
=DATE(YEAR(C2)+5,MONTH(C2),DAY(C2))
-
The YEAR function looks at cell C2 and extracts «2012».
-
Then, «+5» adds 5 years, and establishes «2017» as the anniversary year in cell D2.
-
The MONTH function extracts the «3» from C2. This establishes «3» as the month in cell D2.
-
The DAY function extracts «14» from C2. This establishes «14» as the day in cell D2.
If you open a file that came from another program, Excel will try to recognize dates within the data. But sometimes the dates aren’t recognizable. This is may be because the numbers don’t resemble a typical date, or because the data is formatted as text. If this is the case, you can use the DATE function to convert the information into dates. For example, in the following illustration, cell C2 contains a date that is in the format: YYYYMMDD. It is also formatted as text. To convert it into a date, the DATE function was used in conjunction with the LEFT, MID, and RIGHT functions.
-
The DATE function creates a date.
=DATE(LEFT(C2,4),MID(C2,5,2),RIGHT(C2,2))
-
The LEFT function looks at cell C2 and takes the first 4 characters from the left. This establishes “2014” as the year of the converted date in cell D2.
-
The MID function looks at cell C2. It starts at the 5th character, and then takes 2 characters to the right. This establishes “03” as the month of the converted date in cell D2. Because the formatting of D2 set to Date, the “0” isn’t included in the final result.
-
The RIGHT function looks at cell C2 and takes the first 2 characters starting from the very right and moving left. This establishes “14” as the day of the date in D2.
To increase or decrease a date by a certain number of days, simply add or subtract the number of days to the value or cell reference containing the date.
In the example below, cell A5 contains the date that we want to increase and decrease by 7 days (the value in C5).
See Also
Add or subtract dates
Insert the current date and time in a cell
Fill data automatically in worksheet cells
YEAR function
MONTH function
DAY function
TODAY function
DATEVALUE function
Date and time functions (reference)
All Excel functions (by category)
All Excel functions (alphabetical)
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.
Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.
Excel spreadsheets provide the ability to work with various types of textual and numerical information. Date processing is also available. In this case, there may be a need to extract from the general meaning of a specific number, for example, a year. There are separate functions for this: YEAR, MONTH, DAY and DAY.
Examples of using functions for date processing in Excel
Excel tables store dates that are presented as a sequence of numeric values. It begins on January 1, 1900. This date will correspond to the number 1. At the same time, January 1, 2009 is laid down in the tables, as the number 39813. This is the number of days between the two designated dates.
The function YEAR is used similarly to the adjacent:
- MONTH;
- DAY;
- WEEKDAY.
All of them display numerical values corresponding to the Gregorian calendar. Even if in the Excel spreadsheet, the Hijra calendar was chosen to display the entered date, then when isolating the year and other composite values by functions, the application will present a number that is equivalent to the Gregorian system of chronology.
To use the YEAR function, you need to enter into the cell the following function formula with one argument:
=YEAR(cell address with date in numeric format)
The function argument is required. It can be replaced by «date_number_number». In the examples below, you can clearly see this. It is important to remember that when displaying the date as text (automatic orientation on the left edge of the cell), the YEAR function will not be executed. Its result will be the # SIGN. Therefore, formatted dates must be presented in a numerical version. Days, months and year can be separated by a dot, slash or comma.
Consider an example of working with the YEAR function in Excel. If we need to get a year from the original date, the function AVAILABLE will not help us since it does not work with dates, but only with text and numeric values. To separate the year, month or day from the full date for this, Excel provides functions for working with dates.
Example: There is a table with a list of dates and in each of them it is necessary to separate the value of only the year.
We introduce the original data in Excel.
To solve the problem, it is necessary to enter the formula in the cells of column B:
=YEAR(the address of the cell, from the date of which you need to isolate the year value)
As a result, we extract years from each date.
A similar example of the MONTH function in Excel:
An example of working with functions DAY and WEEKDAY. The DAY function gets to calculate from the date the number of any day:
WEEKDAY function returns the number of the day of the week (1-Monday, 2-Tuesday …, etc.) for any date:
In the second optional argument of the WEEKDAY function, the number 2 may specified for our day of the week countdown format (Monday-1 through Sunday-7):
If you omit the second optional argument, then the default format will be used (English from Sunday-1 to Saturday-7).
Create a formula of the combination of the functions INDEX and WEEKDAY:
We obtain a more understandable form of the implementation of this function.
Examples of the practical use of functions for working with dates
These primitive functions are very useful when grouping data by: years, months, days of the week, and specific days.
Suppose we have a simple sales report:
We need to quickly organize data for visual analysis without using pivot tables. To do this, we will bring the report into a table where it is convenient and quickly to group data by year, month and day of the week:
Now we have a tool to work with this sales report. We can filter and segment data by specific time criteria:
In addition, you can make a histogram to analyze the best-selling days of the week, to understand which day of the week has the largest number of sales:
In this form, it is very convenient to segment sales reports for long, medium and short periods of time.
It should be immediately noted that in order to get the difference between the two dates, none of the above functions will help us. For this task, you should use a specially designed function DATEDIF:
Download examples fo functions YEAR MONTH DAY WEEKDAY and DATEDIF
The type of values in the date cells requires a special approach to data processing. Therefore, you should use the appropriate type of function in Excel.
If you have a date column in your Excel spreadsheet and need to separate it into day, month, and year, you may be wondering how to do so efficiently. This post will guide you through four different methods for splitting a date into day, month and year using Excel formulas, Text to Columns, Flash Fill, and VBA Code. How do I quickly split date as Day, Month and Year using Formulas or Text to Columns feature in Excel.
Table of Contents
- 1. Split Date into Day Month and Year with Formulas
- 2. Split Date into Day Month and Year with Text to Column Feature
- 3. Split Date into Day, Month and Year with Flash Fill Feature
- 4. Split Date into Day, Month and Year with VBA Code
- 5. Video: Split Date into Day Month and Year
- 6. Conclusion
- 7. Related Functions
1. Split Date into Day Month and Year with Formulas
Assuming that you have a list of data in range A1:A6, which contain date values. And you want to split each date value into three separate columns for day, month and year. How to achieve it. You can use three formulas based on the DAY function, the Month function and the Year function to achieve the result of splitting dates. Just do the following steps:
Step1: type Day string in a blank cell in a new column, such as: B1, and type Month string in Cell C1, type Year string in Cell D1.
Step2: Type the following formula in Cell B2, and press Enter key, then drag the AutoFill Handle over to other cells to apply this formula.
=DAY(A2)
This formula will extract Day Value from the given date in range A2:A6.
Step3: Type the following formula based on the Month function to get Month value from date in Cell C2, and press Enter key, and then drag the AutoFill Handle over to other cells to apply this formula.
=MONTH(A2)
This formula will extract Month value from the given date in range A2:A6
Step4: Type the following formula in Cell D3 to get the Year value, and press Enter key, and then drag the AutoFill Handle over other cells.
=Year(A2)
You should see that all dates in range A2:A6 have been split into separate day, month and year.
2. Split Date into Day Month and Year with Text to Column Feature
You can also use Text to Column options to achieve the same result of splitting date into separate day, month and year in three columns. You just need to do the following steps:
Step1: select the range of cells that you want to split.
Step2: go to DATA tab, click Text to Columns command under Sort & Filter group. And the Convert Text to Columns Wizard dialog will open.
Step3: select Delimited as the file type, and click Next button.
Step4: only check Other checkbox under Delimiter section, type the delimiter / into the Other text box, and click Next button.
Step5: select one Destination cell, such as: B2, click Finish button.
Step6: the date column has been split into separate day, month and year.
3. Split Date into Day, Month and Year with Flash Fill Feature
Flash Fill can quickly and easily split a date column into day, month, and year components in Excel. Just do the following steps:
Step1: First select three new columns to the right of the date column.
Step2: In the first new column, enter the first value you want to extract. For example, the day value.
Step3: In the second new column, enter the second value you want to extract. For example, the month value.
Step4: In the third new column, enter the third value you want to extract. For example, the year value.
Step5: Click on the first day value in the first new column, then click on Flash Fill command under Data Tools group in Data tab.
Step6: Excel will automatically show the suggested day values in the remaining cells of the new column.
Step7: Repeat step 6 for the remaining two new columns to extract the month and year values.
Once you have extracted all three values, you can delete the original date column and the temporary columns containing the extracted values.
4. Split Date into Day, Month and Year with VBA Code
You can also use VBA code to split a date into day, month, and year components in Excel. Just do the following steps:
Step1: Open your Excel workbook and press ALT + F11 to open the Visual Basic Editor.
Step2: Click on “Insert” from the top menu and choose “Module” to create a new module.
Step3: Copy and paste the following code into the module, Save the module and close the Visual Basic Editor.
Sub SplitDate_excelgeek() Dim dateRange As Range Set dateRange = Application.InputBox("Select the range of cells containing the dates to split", Type:=8) Dim cell As Range For Each cell In dateRange Dim dayValue As Integer Dim monthValue As Integer Dim yearValue As Integer dayValue = Day(cell.Value) monthValue = Month(cell.Value) yearValue = Year(cell.Value) cell.Offset(0, 1).Value = dayValue cell.Offset(0, 2).Value = monthValue cell.Offset(0, 3).Value = yearValue Next cell End Sub
Step4: Click on “Macros” under the “Code” group. Select the “SplitDate_excelgeek” macro from the list and click on “Run“.
Step5: select the range of cells containing the date values that you want to split. For example, select range of cells A2:A5.
Step6: The VBA Macro will split the selected date column into day, month, and year components and place the results in the adjacent columns.
This video tutorial will guide you on how to split a date into day, month, and year components using various methods in Excel.
6. Conclusion
Whether you need to work with a large dataset or just a few dates, these methods can help you quickly and accurately separate your date values into separate columns.
- Excel YEAR function
The Excel YEAR function returns a four-digit year from a given date value, the year is returned as an integer ranging from 1900 to 9999. The syntax of the YEAR function is as below:=YEAR (serial_number)… - Excel MONTH function
The Excel MONTH function returns the month of a date represented by a serial number. And the month is an integer number from 1 to 12. The syntax of the MONTH function is as below:=MONTH (serial_number)… - Excel DAY function
The Excel DAY function returns a day of a date (from 1 to 31).The DAY function is a build-in function in Microsoft Excel and it is categorized as a DATE and TIME Function.The syntax of the DAY function is as below:= DAY (date_value)…
Sample Files
1. DATE Function
DATE function returns a valid date based on the day, month, and year you input. In simple words, you need to specify all the components of the date and it will create a date out of that.
Syntax
DATE(year,month,day)
Arguments
- year: A number to use as the year.
- month: A number to use as the month.
- day: A number to use as a day.
Example
In the below example, we have used cell references to specify the year, month, and day to create a date.
You can also insert arguments directly into the function to create a date as you can see in the below example.
And in the below example, we have used different types of arguments to see the result returned by the function.
2. DATEVALUE Function
DATEVALUE function returns a date after converting a text (which represents a date) into an actual date. In simple words, it converts a date into an actual date which is formatted as text.
Syntax
DATEVAUE(date_text)
Arguments
- date_text: The date which is stored as a text and you want to convert that text into an actual date.
Example
In the below example, we have inserted a date directly into the function by using double quotation marks. If you skip adding these quotation marks it will return a #NAME? error in the result.
In the below example, all the dates on the left side are in textual format.
- A simple textual date that we have converted into a valid date.
- A date with all three components (Year, Month, or Day) in numbers.
- If there is no year in the textual date, it will take the current year as the year.
- And if you have a month name is in alphabets and no year, it will take the current year as a year.
- If you don’t have the day in your textual date it will take 1 as the day number.
3. DAY Function
DAY function returns the day number from a valid date. As you know, in Excel, a date is a combination of day, month, and year, DAY function gets the day from the date and ignores the rest of the part.
Syntax
DAY(serial_number)
Arguments
- serial_number: A valid serial number of the date from which you want to extract the day number.
Example
In the below example, we have used the DAY to simply get the day from a date.
And in the below example, we have used DAY with TODAY to create a dynamic formula that returns the current day number and it will update every time you open your worksheet or when you recalculate your worksheet.
5. DAYS Function
DAYS function returns the difference between two dates. It takes a start date and an end date and then returns the difference between them in days. This function was introduced in Excel 2013 so not available in prior versions.
Syntax
DAYS(end_date,start_date)
Arguments
- start_date: It is a valid date from where you want to start the days’ calculation.
- end_date: It is a valid date from where you want to end the days’ calculation.
Example
In the below example, we have referred the cell A1 as the start date and B1 as the end date and we have 9 days in the result.
Note: You can also use the subtract operator to get the difference between two dates.
In the below example, we have directly inserted two dates into the function to get the difference between them.
6. EDATE Function
EDATE function returns a date after adding a specified number of months to it. In simple words, you can add (with a positive number) or subtract (with a negative number) months from a date.
Syntax
EDATE(start_date,months)
Arguments
- start_date: The date from which you want to start the calculation.
- months: The number of months to calculate the future or the past date.
Example
Here we have used EDATE with different types of arguments.
- In the first example, we have used 5 as a several months and it has added exactly 5 months on 1-Jan-2016 and returned 01-June-2016.
- In the second example, we have used -1 month and it has given 31-Dec-2016, a date which is exactly 1 month back from 31-Jan-2016.
- In the third example, we have inserted a date directly into the function.
7. EOMONTH Function
EOMONTH function returns the end of the month date which is the number of months in the future or the past. You can use a positive number for a future date and a negative number for the past month’s date.
Syntax
EOMONTH(start_date,months)
Arguments
- start_date: A valid date from where you want to start your calculation.
- months: The number of months you want to calculate before and after the start date.
Example
In the below example, we have used EOMONTH with different types of arguments:
- We have mentioned 01-Jan-2016 as the start date and 5 months for getting a future date. As June is exactly 5 months after January, it has returned 30-Jun-2016 in the result.
- As I have already mentioned, EOMMONTH is smart enough to evaluate the total number of days in a month.
- If you mention a negative number, it simply returns a past date which is the number of months back you have mentioned.
- In the fourth example, we have used a date that is in text format and it has returned the date without returning any errors.
8. MONTH Function
MONTH function returns the month number (ranging from 0 to 12) from a valid date. As you know, in Excel, a date is a combination of day, month, and year, MONTH gets the month from the date and ignores the rest of the part.
Syntax
MONTH(serial_number)
Arguments
- serial_number: A valid date from which you want to get the month number.
Example
In the below example, we have used a MONTH in three different ways:
- In the FIRST example, we have simply used date and it has returned the 5 in the result which is the month number of MAY.
- In the SECOND example, we have supplied the date directly in the function.
- In the THIRD example, we have used the TODAY function to get the current date and MONTH has returned the month number from it.
9. NETWORKDAYS Function
NETWORKDAYS function returns the count of days between the start date and end date. In simple words, with NETWORKDAYS you can calculate the difference between two dates, after excluding Saturdays and Sundays, and holidays (which you specify).
Syntax
NETWORKDAYS(start_date,end_date,holidays)
Arguments
- start_date: A valid date from where you want to start your calculation.
- end_date: A valid date up to which you want to calculate working days.
- [holidays]: A valid date that represents a holiday between the start date and end date. You can refer to a cell, range of cells, or an array containing dates.
Example
In the below example, we have specified 10-Jan-2015 as a start date and 20-Feb-2015 as an end date.
We have 41 days between these two dates, out of which 11 days are weekends. After deducting those 11 days it has returned 30 working days.
Now in the below example with the same start and end dates, we have specified a holiday and, after deducting 11 days of the weekend and 1 holiday it has returned 29 working days.
Again with the same start and end dates, we have used a range of three cells for holidays to deduct from the calculation and, after deducting 11 weekend days and 3 holidays which I have mentioned It has returned 27 working days.
10. NETWORKDAYS.INTL Function
NETWORKDAYS.INTL Function returns the count of days between the start date and end date. Unlike NETWORKDAYS, NETWORKDAYS.INTL lets you specify which days you want to exclude from the calculation.
Syntax
NETWORKDAYS.INTL(start_date,end_date,weekend,holidays)
Arguments
- start_date: A valid date from where you want to start your calculation.
- end_date: A valid date up to which you want to calculate working days.
- [weekend]: A number represents to exclude weekends from the calculation.
- [holidays]: A list of dates that represents the holidays you want to exclude from the calculation.
Example
In the below example, we have used 01-Jan-2015 as a start date and 20-Jan-2015 as an end date. And we have specified 1 to take Sunday – Saturday as the weekend. The function has returned 14 days after excluding 6 weekend days.
Below, we have used the same dates. And I have used 11 in for weekend days which means it will only consider Sunday as a weekend. Along with that, we have also used 10-Jan-2015 as a holiday.
We have 3 Sundays between both dates and a holiday. After excluding all these days the function has returned 16 days in the result. Here in the below example, we have used range to specify holidays. If you have more than one date for the holidays you can refer to an entire range.
Quick Tip: If you want to create a dynamic range for holidays, you can use a table for that. If you want to choose custom days to count as working days or weekends, you can use the below format in the weekend argument.
Here, 0 represents a working day and 1 represents a non-working day. And, seven numbers represent 7 days of the week.
11. TODAY Function
The TODAY function returns the current date and time as per the system’s date and time. The date and time returned by the NOW function update continuously whenever you update anything in the worksheet.
Syntax
TODAY()
Arguments
- In the TODAY function, there is no argument, all you need to do is enter it in the cell and hit enter, but be careful as TODAY is a volatile function which updates its value every time you update your worksheet calculations.
Example
In the below example, we have used TODAY with other functions to get the current month number, current year, and current day.
12. WEEKDAY Function
WEEKDAY function returns a day number (ranging from 0 to 7) of the week from a date. In simple words, the WEEKDAY function takes a date and returns the day number of that date’s day.
Syntax
WEEKDAY (serial_number, [return_type])
Arguments
- serial_number: A valid date from which you want to get the week number.
- [return_type]: A number that represents the day of the week to start the week.
Example
In the below example, we have used a WEEKDAY with TODAY to get a dynamic weekday. It will give you the weekday whenever the current date changes. You can use this method in your dashboards to trigger some values which need to change when weekday change.
In the below example, we have used WEEKDAY with IF to create a formula that first checks the weekday of date and return “Weekday” or “Weekend” basis on the value return from WEEKDAY.
13. WEEKNUM Function
WEEKNUM function returns the week number of a date. In simple words, WEEKNUM returns the week number of dates that you specify ranging from 1 to 54.
Syntax
WEEKNUM(serial_number,return_type)
Arguments
- serial_number: A date for which you want to get the week number.
- [return_type]: A number to specify the starting day of the first week of the year. You have two systems to specify the starting date of the week.
Example
In the below example, we have used TODAY with WEEKNUM to get the week number of the current date. It will update the week number automatically every time the date changes.
In the below example, we have added the text “Week-” with the week number for a meaningful result.
14. YEAR Function
YEAR Function returns the year number from a valid date. As you know, in Excel a date is a combination of day, month, and year, and the YEAR function gets the year from the date and ignores the rest of the part.
Syntax
YEAR(date)
Arguments
- date: A date from which you want to get the year.
Example
In the below example, we have used the year function to get the year number from the dates. You can use this function where you have dates in your data and you only need the year number.
And in the below example, we have used today function to get the year number from the current date. It will always update the year whenever you recalculate your worksheet.
How to Use Excel > Excel Formula > How to Extract Day, Month and Year from Date in Excel
How to Extract Day, Month and Year from Date in Excel
Table of contents :
- Extract Day from Date in Excel
- Extract Month from Date in Excel
- Extract Year from Date in Excel
Excel provides three different functions to extract a day, month, and year from date. The following is an explanation of each function to extract each value.
Extract Day from Date in Excel
The formula
=DAY(A2)
The result
If you want to extract the day from the date, you can use the DAY function. The DAY function requires only one argument, fill it with valid excel date value.
The result, there are four days value and one error #VALUE!. An error occurred because 2/29/2006 is not a valid Excel date value. Why? Because 2006 is not a leap year, so there is no February 29th.
The DAY function result is a number between 1 and 31.
Extract Month from Date in Excel
The formula
=MONTH(A2)
The result
To extract month from the date you need the MONTH function. Like the DAY function, the MONTH function has only one argument, filled with a valid Excel date value.
There is a #VALUE error. The error appearance is the same place as the #VALUE error in DAY function result. The cause of the error is the same; the date value in cell A5 is not a valid Excel date value. This error will still appear in all excel functions related to the date.
The MONTH function result is a number between 1 and 12.
Extract Year from Date in Excel
The formula
=YEAR(A2)
The result
To extract the year from date, Excel provides the YEAR function. There is an argument that must be filled with a valid Excel date value.
The results of the DAY and MONTH functions are a number with a narrow range. Instead, the YEAR function is a wide range of numbers between 1900 and 9999.
For years less than 1900 or more than 9999, it will be considered an invalid excel date value. If used by an Excel function (related to the date function) returns a #VALUE! Error.
The DAY, MONTH and YEAR functions extract day, month and year from a date. To do the opposite, converting day, month and year in number to date value, you need the DATE function.
Related Function
Function used in this article