Converting Data in Spreadsheets

### How to convert 8-digit number to date in Excel

It's a very common situation when a date is input as an 8-digit number like 10032016, and you need to convert it into a date value that Excel can recognize (10/03/2016). In this case, simply changing the cell format to Date won't work - you will get ########## as the result.

To convert such a number to date, you will have to use the DATE function in combination with RIGHT, LEFT and MID functions. Unfortunately, it is not possible to make a universal formula that will work in all scenarios because the original number can be input in a variety of different formats. For example:

 10032016
 20160310
 20161003

Anyway, I will try to explain the general approach to converting such numbers to dates and provide a few formula examples.

For starters, remember the order of the Excel Date function arguments:

DATE(year, month, day)

So, what you need to do is extract a year, month and date from the original number and supply them as the corresponding arguments to the Date function.

For example, let's see how you can convert number 10032016 (stored in cell A1) to date 3/10/2016.

* Extract the year. It's the last 4 digits, so we use the RIGHT function to pick the last 4 characters: RIGHT(A1, 4).
* Extract the month. It's the 3rd and 4th digits, so we employ the MID function to get them MID(A1, 3, 2). Where 3 (second argument) is the start number, and 2 (third argument) is the number of characters to extract.
* Extract the day. It's the first 2 digits, so we have the LEFT function to return the first 2 characters: LEFT(A2,2).

Finally, embed the above ingredients into the Date function, and you get a formula to convert number to date in Excel:

`=DATE(RIGHT(A1,4), MID(A1,3,2), LEFT(A1,2))`

The following screenshot demonstrates this and a couple more formulas in action:

Please pay attention to the last formula in the above screenshot (row 6). The original number-date (161003) contains only 2 chars representing a year (16). So, to get the year of 2016, we concatenate 20 and 16 using the following formula: 20&LEFT(A6,2). If you don't do this, the Date function will return 1916 by default, which is a bit weird as if Microsoft still lived in the 20th century :)

## How to convert text to date in Excel

When you spot text dates in your Excel file, most likely you would want to convert those text strings to normal Excel dates so that you can refer to them in your formulas to perform various calculations. And as is often the case in Excel, there are a few ways to tackle the task.

### Excel DATEVALUE function - change text to date

The DATEVALUE function in Excel converts a date in the text format to a serial number that Excel recognizes as a date.

The syntax of Excel's DATEVALUE is very straightforward:

DATEVALUE(date\_text)

So, the formula to convert a text value to date is as simple as `=DATEVALUE(A1)`, where A1 is a cell with a date stored as a text string.

Because the Excel DATEVALUE function converts a text date to a serial number, you will have to make that number look like a date by applying the Date format to it, as we discussed a moment ago.

The following screenshots demonstrates a few Excel DATEVALUE formulas in action:

#### Excel DATEVALUE function - things to remember

When converting a text string to a date using the DATEVALUE function, please keep in mind that:

* Time information in text strings is ignored, as you can see in rows 6 and 8 above. To convert text values containing both dates and times, use the VALUE function.
* If the year is omitted in a text date, Excel's DATEVALUE will pick the current year from your computer's system clock, as demonstrated in row 4 above.
* Since Microsoft Excel stores dates since January 1, 1900 , the use of the Excel DATEVALUE function on earlier dates will result in the #VALUE! error.
* The DATEVALUE function cannot convert a numeric value to date, nor can it process a text string that looks like a number, for that you will need to use the Excel VALUE function, and this is exactly what we are going to discuss next.

### Excel VALUE function - convert a text string to date

Compared to DATEVALUE, the Excel VALUE function is more versatile. It can convert any text string that looks like a date or number into a number, which you can easily change to a date format of your choosing.

The syntax of the VALUE function is as follows:

VALUE(text)

Where `text` is a text string or reference to a cell containing the text you want to convert to number.

The Excel VALUE function can process both date and time, the latter is converted to a decimal portion, as you can see in row 6 in the following screenshot:

### Mathematical operations to convert text to dates

Apart from using specific Excel functions such as VALUE and DATEVALUE, you can perform a simple mathematical operation to force Excel to do a text-to-date conversion for you. The required condition is that an operation should not change the date's value (serial number). Sounds a bit tricky? The following examples will make things easy!

Assuming that your text date is in cell A1, you can use any of the following formulas, and then apply the Date format to the cell:

* Addition: `=A1 + 0`
* Multiplication: `=A1 * 1`
* Division: `=A1 / 1`
* Double negation: `=--A1`

As you can see in the above screenshot, mathematical operations can convert dates (rows 2 and 4), times (row 6) as well as numbers formatted as text (row 8). Sometimes the result is even displayed as a date automatically, and you don't have to bother about changing the cell format.

### How to convert text strings with custom delimiters to dates

If your text dates contain some delimiter other than a forward slash (/) or dash (-), Excel functions won't be able to recognize them as dates and return the #VALUE! error.

To fix this, you can run Excel's Find and Replace tool to replace your delimiter with a slash (/), all in one go:

* Select all the text strings you want to convert to dates.
* Press Ctrl+H to open the *Find and Replace* dialog box.
* Enter your custom separator (a dot in this example) in the *Find what* field, and a slash in the *Replace with*
* Click the *Replace All*

Now, the DATEVALUE or VALUE function should have no problem with converting the text strings to dates. In the same manner, you can fix dates containing any other delimiter, e.g. a space or a backward slash.

If you prefer a formula solution, you can use Excel's SUBSTITUTE function instead of *Replace All* to switch your delimiters to slashes.

Assuming the text strings are in column A, a SUBSTITUTE formula may look as follows:

`=SUBSTITUTE(A1, ".", "/")`

Where A1 is a text date and "." is the delimiter your strings are separated with.

Now, let's embed this SUBSTITUTE function into the VALUE formula:

`=VALUE(SUBSTITUTE(A1, ".", "/"))`

And have the text strings converted to dates, all with a single formula.

As you see, the Excel DATEVALUE and VALUE functions are quite powerful, but both have their limits. For example, if you are trying to convert complex text strings like *Thursday, January 01, 2015,* neither function could help. Luckily, there is a non-formula solution that can handle this task and the next section explains the detailed steps.

## Combine data with the Ampersand symbol (&)

1. Select the cell where you want to put the combined data.
2. Type = and select the first cell you want to combine.
3. Type & and use quotation marks with a space enclosed.
4. Select the next cell you want to combine and press enter. An example formula might be =A2&" "&B2.

## Combine data using the CONCAT function

1. Select the cell where you want to put the combined data.
2. Type =CONCAT(.
3. Select the cell you want to combine first. Use commas to separate the cells you are combining and use quotation marks to add spaces, commas, or other text.
4. Close the formula with a parenthesis and press Enter. An example formula might be =CONCAT(A2, " Family").

## Display numbers as percentages

To quickly apply percentage formatting to selected cells, click Percent Style  in the Number group on the Home tab, or press Ctrl+Shift+%. If you want more control over the format, or you want to change other aspects of formatting for your selection, you can follow these steps.

1. On the Home tab, in the Number group, click the icon next to Number to display the Format Cells dialog box.
2. In the Format Cells dialog box, in the Category list, click Percentage.
3. In the Decimal places box, enter the number of decimal places that you want to display. For example, if you want to see 10% instead of 10.00%, enter 0 in the Decimal places box.