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
Non-linear Components
In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial
Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML)
A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Steady State Response
In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We
9 min read
Backpropagation in Neural Network
Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
Polymorphism in Java
Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
3-Phase Inverter
An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
What is Vacuum Circuit Breaker?
A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
AVL Tree Data Structure
An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. The absolute difference between the heights of the left subtree and the right subtree for any node is known as the balance factor of
4 min read
What is a Neural Network?
Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns, and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamenta
14 min read