How To Convert Date To Number String Or Text Format In Excel?
Last Updated :
16 Nov, 2022
Excel's built-in date system by default supports dates between January 1, 1900, and December 31, 9999. In this range, the numbers start at 1 and increase by 1 each time. In addition to text and numeric data types, Excel also allows dates that are internally stored as serial numbers. In Excel, the date format is typically recognized by default. However, Excel also allows you to input date format by choosing the cell and pressing (Ctrl+;).
Methods to Convert Date to Number String
DATEVALUE Function
Syntax: =DATEVALUE (date_text)
Where date_text is the only argument
DATEVALUE FunctionCell Formatting
Step 1: Once the cell with the value has been chosen, click the home tab and choose the NUMBER or TEXT option.
Step 2: The cell format then changes into the original serial number internally stored by Excel.
Note: The first serial number stored by excel is of date 01/01/1900.
Methods to Convert Date to Text
TEXT Function
It is used to convert a date into a specified text format.
Syntax: =TEXT(value, format_text)
For today’s date: =TEXT(TODAY(), format_text)
Where value: The value that needs to be converted. This could be a numeric cell reference or value, or a numeric value returned by a formula.
format_text: The format to display the number. It should be in double quotes.
There are different formats possible for the day, month, year, and separator.
| Value
| Meaning
|
---|
Day | - d
- dd
- ddd
- dddd
| - Number without leading 0 (Eg: 6)
- Number with leading 0 (Eg: 06)
- Day in short form (Eg: Mon)
- Day in full form (Eg: Monday)
|
---|
Month | - m
- mm
- mmm
- mmmm
| - Month number without leading 0 (Eg: 8)
- Month number with leading 0 (Eg: 08)
- Month three-letter abbreviation (Eg: Jan)
- Month full form (Eg: January)
|
---|
Year | - yy
- yyyy
| - Year in two-digit (Eg: 16)
- Year in four-digit (Eg: 2016)
|
---|
Separator | - / (slash)
- - (dash)
- . (dot)
- , (comma)
| - 10/10/2020
- 10-10-2020
- 10.10.2020
- 10 Oct, 2020
|
---|
Adding Apostrophe
An apostrophe can be added in the formula bar where the date is entered to make it text. In some excel versions, adding space in the formula bar adds the apostrophe itself.
Format Cell Option
Step 1: Either select the cells, right click and click on the FORMAT CELL option, or in the Home Tab, select Cell then format and click on the FORMAT CELL.
Step 2: In the Custom option of the Number Tab, specify the format. Click Ok.
Text to Column
Step 1: Select the cells. Go to the Data tools in the Data tab. Click on Text to Column.
Step 2: In the next widget, choose delimited and click next.
Step 3: In the next screen, deselect all the delimiters and click next.
Step 4: Finally, enter the destination cell number and click finish.
Note: The Text to Column tool will always convert dates to the short date format according to your system.
Copy-Paste Through Notepad
Step 1: Copy the selected cells with date and paste them to Notepad. The dates are instantly transformed into text when pasted into the notepad.
Step 2: The target cells should be chosen and changed to the Text Cell Format in the next step.
Step 3: Finally, paste the content in the target cells. It will be in the text format as shown in the figure.
VBA
VBA is located in Excel's "Developer" tab.
Step 1: The "Developer" tab must first be enabled before it can be accessed from the 'File' option.
Step 2: Select Customize Ribbon from Options. Check the Developer box from the right menu.
VBA is now enabled. We can access VBA Editor through the Developer tab or the keyboard shortcut ALT + F11.
Visual Basic from Developer Tab
Step 3: Insert Module in the workbook.
Step 4: Add the following code to convert Date to Text. Name the function ToText in the blank next to General. Click on Run Button.
Sub toText()
Dim d as Range
For Each d in Selection
d.Value = Format(d.Value, “dd.mm.yyyy”)
Next d
End Sub
Step 5: In the next Dialog Box, click No and change the Extension to “Excel Macro-Enabled Workbook” to save it.
Step 6: Macros in VBA are a collection of codes that form a programming language. In the excel sheet, add a macro button for the above code by adding a shape/ text box. Add the text "Convert to Text" in the shape.
Step 7: Right-click the text box and choose “Assign Macro” for the toText code to make it a clickable button.
Step 7: Assign macro to the button
Finally, using the created button, we can change the date to text in the format specified in the code.
Similar Reads
How to Convert Text to Date in Excel
Have you ever found yourself staring at a column of dates in Excel, only to realize theyâre formatted as text? It's a common problem that can hinder your data analysis and reporting tasks. Fortunately, converting text to date in Excel is straightforward. If you're looking to use the Text to Columns
5 min read
How to Convert Scientific Notation to Text or Number in Excel?
Microsoft Excel is a universal software tool that is used by companies throughout the world to store data/numbers in the form of a spreadsheet. Excel not only helps users to store the data into spreadsheets, but it also gives us the freedom to use multiple smart features to manipulate, organize and
5 min read
How to Convert Numbers to Dates in R?
In this article, we will discuss how to convert Numbers to Dates in R programming language. Method 1: Convert Integer to Date Using as.Date() & as.character() Functions Here we have to consider an integer and then first we have to convert that integer into a character using as.character() functi
2 min read
How to Convert String to Date Time in Scala?
In this article, we will learn how to convert String to DateTime in Scala. Converting String to DateTime consists of parsing a textual representation of date and time into a structured DateTime object for further manipulation and processing in Scala programs. Table of Content Using SimpleDateFormatU
4 min read
How to Convert Date to Numeric in R?
In this article, we will discuss how to convert date to numeric in R Programming Language. Method 1: Using as.numeric() This function is used to convert date into numeric Syntax: as.numeric(date) where the date is the input date. Example: R data = as.POSIXct("1/1/2021 1:05:00 AM", format="%m/%d/%Y %
2 min read
Convert Excel to Google Sheets [Without Losing Formatting]
Many professionals and students are switching to Google Sheets because itâs free, easy to use, and perfect for sharing and editing data in real time. But if youâve got Excel files on hand, you might be wondering: How do I convert Excel to Google Sheets without losing formatting or formulas?This guid
5 min read
How to Change Date Format in Excel
You know that Excel is one of the best spreadsheets you can work on. Excel is the first preference of many users to create an impressive data set. Have you tried filling in the Date on the sheet? Date with the data is a common practice done by users in Excel to get information timeline. To help orga
8 min read
How to Combine Text with Date or Time in Excel?
Microsoft Excel allows its users to store and manage different varieties of data in the form of rows and columns and store it inside an Excel workbook. Since Microsoft Excel allows its users to not only store data but also manipulate that data later on as per their needs. Combine Text with Date or T
4 min read
How to use moment.js to change date format in jQuery ?
Using Moment.js to change date format in jQuery involves importing the Moment.js library and utilizing its functions to parse, manipulate, and format dates. You can easily convert dates into various formats by calling moment(date).format(desiredFormat) to display the date in your preferred format.mo
2 min read
How to convert a factor into date format?
Factors cannot be used as a date directly thus if some functionality requires a date format, a factor can be converted to one. In this article, we will be looking at two different approaches to converting factors to date in the R programming language. Method 1: Using as.Date() FunctionIn this method
4 min read