In many situations, we need to convert a date to a number in Excel to accomplish a calculation. Working with date and time values is one of the trickiest parts of Excel. People store dates in different formats as the combination of day, month, and year. But what Excel does do to recognize a date? It stores dates as a number in the backend. In this article, we’ll get to know the methods that transform a date into a number.
1. Converting the Date to a Serial Number in Excel with the DATEVALUE Function
We will convert a date to a number in Excel. Here is an overview of the final result.
NOTE: As we know Excel stores dates as serial numbers in its system. This serial number starts from 1 on the date 1/1/1900 and increases by 1 onwards.
The DATEVALUE function in Excel converts a text-formatted date to a serial number that is recognizable as a date to Excel.
Syntax of the DATEVALUE function:
Let’s follow the example:
#Example 1: DATEVALUE Function Argument in the Date Format
If the argument for the DATEVALUE function is in the date format, then we need to put the date inside double quotes to make the function work. See the screenshots below:
Screenshot 1: We can see that the selected column is in the date format.
Screenshot 2: We put the date inside a double quote to make it text for the DATEVALUE function and then hit ENTER.
The DATEVALUE function converted the date into a serial number.
#Example 2: DATEVALUE Function Argument in the Text Format
If the argument for the DATEVALUE function is in the Text format, then we just need to put the date inside the function to transform it into a serial number. Let’s follow the screenshots:
Screenshot 1: Here the selected cells contained a list of dates in Text format.
Screenshot 2: Here in cell H6, we put F6 as the argument which contains the date 1/1/2022 (in Date format), and hit Enter to convert it to a serial number.
2. Converting Date to a Serial Number Changing the Formatting
In this method, we’ll use the Home tab of the Excel ribbon to transform a date into a 5-digit serial number.
- This screenshot shows a list of dates in the Date format. From the Home tab, navigate to the Number section, there is a box that shows the format of the selected cells and options to change into another format.
- Now from the format options choose the General or the Number option.
- The above step will turn the date into a 5-digit serial number.
Similarly, we can have all other dates converted into a serial number.
3. Using Format Cells Dialog Box for Converting Date to Number
Open the Cell Formatting Option (3 ways):
- The Context Menu in Excel provides the option of Cell Formatting named Format Cells. With the option of cell formatting, we can change the format for the selected cell. We can open the context menu by simply clicking the right button of our mouse on the selected cell.
- We can also go to the Cells section from the Home tab.
- From the Format tab, select the Format Cells option.
- Press Alt + H + O + E on your keyboard to make the Format Cells window visible.
Now you have the Format Cells window opened. In the Number tab, select General from the Category list. This time we selected all the cells that contain dates, together. Finally, don’t forget to click the OK button.
4. Using Custom Formatting to Transform the Date to an 8-digit Number (mmddyyyy or ddmmyyyy Format)
By following the ways (click here to see the ways) described in the previous method, we can open the cell formatting options easily. Then follow the steps below:
- Go to the Number tab.
- Select the Custom option from the Category.
- Put mmddyyyy in the Type input box.
- Finally, click the OK button.
- The above steps converted all the dates into 8-digit numbers in the mmddyyyy format. We can see the first 2 digits represent the month, the following 2 digits represent the day, and the last 4 digits are the year.
Following the same procedure, we can have different formats like ddmmyyyy, yyyymmdd, etc.
Here is an overview:
Read More: How to Convert Date to Text YYYYMMDD
Things to Remember
- Sometimes it may happen while converting a date to a number, the result shows #### in the cell. It happens when the cell width is not enough to hold the serial numbers. Increasing the cell width will solve it immediately.
- While using the default date system of Microsoft Excel for Windows the argument value must be in a range from January 1, 1900, to December 31, 9999. It fails to handle a date beyond this range.
Download Practice Workbook
Download this practice workbook to exercise while you are reading this article.
Now, that we know the methods to convert a date to a number in Excel, it would encourage you to use this feature more confidently. Any questions or suggestions don’t forget to put them in the comment box below.
- How to Convert Date to Day of Week in Excel
- How to Convert Date to Day of Year in Excel
- How to Convert Date to Month in Excel
- Convert Date to Day of Year in Excel
- How to Convert Date to Month and Year in Excel
- How to Convert Date to Quarter and Year in Excel
- How to Convert Date to Day in Excel