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
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.
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.
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.
You should see that all dates in range A2:A6 have been split into separate day, month and year.
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.Note: If Flash Fill doesn’t work in your Excel version, you can enable it by clicking on File tab in the Excel Ribbon, and select Options from the menu,click on Advanced in the left-hand pane, Scroll down to the Editing options section, check the box next to “Automatically Flash Fill” if they are not already checked.
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.
5. Video: Split Date into Day Month and Year
This video tutorial will guide you on how to split a date into day, month, and year components using various methods in Excel.
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.
7. Related Functions
- 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)…