# How to use the DATEVALUE function

**What is the DATEVALUE function?**

The DATEVALUE function returns an Excel date value (serial number) based on a date stored as text.

#### Table of Contents

## 1. Introduction

**What are dates in Excel?**

Dates are stored numerically but formatted to display in human-readable date/time formats, this enables Excel to do work with dates in calculations.

For example, dates are stored as sequential serial numbers with 1 being January 1, 1900 by default. The integer part (whole number) represents the date the decimal part represents the time.

This allows dates to easily be formatted to display in many date/time formats like mm/dd/yyyy, dd/mm/yyyy and so on and still be part of calculations as long as the date is stored numerically in a cell.

You can try this yourself, type 10000 in a cell, press CTRL + 1 and change the cell's formatting to date, press with left mouse button on OK. The cell now shows 5/18/1927.

**Why are dates stored as text in Excel?**

Dates are not stored as text in Excel they are stored as numbers, however, Excel tries to identify values as text, numbers, Boolean values, dates, and time automatically but may fail in rare occasions.

This may happen when you import data from the internet, databases, text files, and other sources. You can convert the dates to Excel dates if you like but it can be a tedious and time consuming task.

The DATEVALUE function lets you convert the text date in the formula to an Excel date without you first converting them on the worksheet.

**How to enter valid dates in Excel?**

Valid dates are right-aligned in a cell just like numbers, invalid dates are identified as text values and left-aligned. The image above shows that / (forward slash) and - (dash) are valid delimiting characters in Excel dates, demonstrated in cells B2 and B3.

A dot and no delimiters at all, shown in cells B4 and B5, are invalid, these dates are left-aligned by Excel. The DATEVALUE cant properly identify these date values either, you need to change these dates by hand or using the methods described below.

## 2. DATEVALUE function Syntax

DATEVALUE(*date_text*)

## 3. DATEVALUE function Arguments

date_text |
Required. The date stored as text you want to convert to an Excel date (serial number). |

## 4. DATEVALUE function example

A date stored as text can't be sorted, filtered or be used in Excel date calculations. You need to convert the date stored as text to a date that Excel recognizes. The image above shows dates stored as text in cell range B3:B7.

Formula in cell C3:

### Explaining formula

DATEVALUE(B3)

becomes

DATEVALUE("1/4/2013")

and returns

41278 which is the corresponding serial number Excel uses for the date "1/4/2013".

## 5. DATEVALUE function not working

The DATEVALUE function returns an Excel date value (serial number) based on a date stored as text. However, it must be a valid text date which is determined by your date and time settings (national settings) on your operating system.

Formula in cell C3:

### 5.1. Verify your date and time settings

Microsoft recommends that you verify your date and time settings so they are compatible with the text date format. On a "Windows 10" operating system open the Control Panel and then "National Settings" and see if you can find a supported date setting. Both the short and long dates must match.

### 5.2. Convert a text date to an Excel date using a formula

I could not find a setting that worked with the text date above so I created the following formula in cell C3.

The picture above shows the output of the formula in column C.

### 5.2.3. Explaining the formula in cell C3

#### Step 1 - Extract year from string

To extract the year from the text date in cell B3 I simply use the RIGHT function to extract the 4 last characters.

The RIGHT function extracts a specific number of characters always starting from the right.

RIGHT(*text*,[*num_chars*])

RIGHT(B3, 4)

becomes

RIGHT("Jan 21 1996", 4)

and returns 1996.

#### Step 2 - Extract month abbreviation from string

The month number is a little harder since it is built of three letters. To get the three letters from B3 I use the LEFT function.

The LEFT function extracts a specific number of characters always starting from the left.

LEFT(*text*, [*num_chars*])

LEFT(B3, 3)

becomes

LEFT("Jan 21 1996", 3)

and returns "Jan".

#### Step 3 - Convert month to a number

The MATCH function returns the relative position of an item in an array or cell reference that matches a specified value in a specific order.

MATCH(*lookup_value, lookup_array, [match_type]*)

MATCH(LEFT(B3, 3), {"Jan"; "Feb"; "Mar"; "Apr"; "May"; "Jun"; "Jul"; "Aug"; "Sep"; "Oct"; "Nov"; "Dec"}, 0)

becomes

MATCH("**Jan**", {"**Jan**"; "Feb"; "Mar"; "Apr"; "May"; "Jun"; "Jul"; "Aug"; "Sep"; "Oct"; "Nov"; "Dec"}, 0)

and returns 1. "Jan" is the first value in the array.

#### Step 4 - Extract day from string

The MID function returns a substring from a string based on the starting position and the number of characters you want to extract.

MID(*text, start_num, num_chars*)

MID(B3, 4, 3)

becomes

MID("Jan 21 1996", 4, 3)

and returns " 21".

#### Step 5 - Create an Excel date

The DATE function allows you to create an Excel date based on a year, month, and day number.

The arguments are DATE(*year*, *month*, *day*).

DATE(RIGHT(B3, 4), MATCH(LEFT(B3, 3), {"Jan"; "Feb"; "Mar"; "Apr"; "May"; "Jun"; "Jul"; "Aug"; "Sep"; "Oct"; "Nov"; "Dec"}, 0), MID(B3, 4, 3))

becomes

DATE(1996, 1, 21)

and returns 1/21/1996 in cell C3.

### Get Excel *.xlsx file

DATEVALUE function not working.xlsx

### 5.3 Example

This example shows that the DATEVALUE function can't handle a date with a dot as a delimiting character.

Formula in cell D3:

The DATEVALUE function returns a #VALUE! error.

**How to create an Excel date from dates using dots as delimiting characters?**

The SUBSTITUTE function lets you replace a given text string with a new text string.

Formula in cell D3 that works:

### Explaining formula

#### Step 1 - Substitute dots with forward slash

The SUBSTITUTE function replaces a specific text string in a value. Case sensitive.

Function syntax: SUBSTITUTE(text, old_text, new_text, [instance_num])

SUBSTITUTE(B3,".","/")

becomes

SUBSTITUTE("1.4.2013",".","/")

and returns

"1/4/2013".

#### Step 2 - Convert text date to an Excel date

The DATEVALUE function returns an Excel date value (serial number) based on a date stored as text.

Function syntax: DATEVALUE(date_text)

DATEVALUE(SUBSTITUTE(B3,".","/"))

becomes

DATEVALUE("1/4/2013")

and returns 41278. Here is how to format the cell value as a date:

- Select the cell (D3).
- Press CTRL + 1 to open the "Format Cells.." dialog box.

- Select category : Date
- Pick a date formatting.
- Press with mouse on the "OK" button.

This example shows that the DATEVALUE function can't handle a date without delimiting characters.

Formula in cell D3:

The DATEVALUE function returns a #VALUE! error.

**How to create an Excel date from dates without delimiting characters?**

Formula in cell D3 that works:

### Explaining formula

#### Step 1 - Extract year from date

The RIGHT function extracts a specific number of characters always starting from the right.

Function syntax: RIGHT(text,[num_chars])

RIGHT(B3,4)

becomes

RIGHT("01042013",4)

and returns "2013".

#### Step 2 - Extract month from date

The LEFT function extracts a specific number of characters always starting from the left.

Function syntax: LEFT(text, [num_chars])

LEFT(B3,2)

becomes

LEFT("01042013",2)

and returns "01".

#### Step 3 - Extract day from date

The MID function returns a substring from a string based on the starting position and the number of characters you want to extract.

Function syntax: MID(text, start_num, num_chars)

MID(B3,3,2)

becomes

MID("01042013",3,2)

and returns "04".

#### Step 4 - Convert to an Excel date

The DATE function returns a number that acts as a date in the Excel environment.

Function syntax: DATE(year, month, day)

DATE(RIGHT(B3,4),LEFT(B3,2),MID(B3,3,2))

becomes

DATE("2013","01","04")

and returns 41278.

### 'DATEVALUE' function examples

Table of Contents How to use the DATE function How to use the DATEDIF function How to use the DATEVALUE […]

This article demonstrates how to match a specified date to date ranges. The image above shows a formula in cell […]

### Functions in 'Date and Time' category

The DATEVALUE function function is one of 22 functions in the 'Date and Time' category.

### Excel function categories

### Excel categories

### 2 Responses to “How to use the DATEVALUE function”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

Hi, Oscar

Result 4/19/2896 is strange.

Alternative formula...

=--SUBSTITUTE(TRIM(B3)," ",", ",2)

aMareis,

Result 4/19/2896 is strange.I didn't see that. Yes, there is a space character that makes it weird.

=--SUBSTITUTE(TRIM(B3)," ",", ",2)Great formula, thanks for your valuable comment.