Reputation: 121
There is a column in Excel with following data.
15052015
19012014
13022013
I want to get that column data in date type (mm/dd/yyyy) and need to have following results:
05/15/2015
01/19/2014
02/13/2013
Upvotes: 2
Views: 160
Reputation: 172378
Try like this:
=(MID(A1,3,2)&"/"&LEFT(A1,2)&"/"&RIGHT(A1,4))
You can try to format your data by doing some manipulation on the cell and adding this formula in your cell.
Upvotes: 1
Reputation:
Select the column of numbers and choose Data ► Data Tools ► Text to Columns. Opt for 🔘 Fixed Width, Next. Then Next. Then for the Column data format opt for Date and choose DMY. Click Finish.
In VBA, the Range.TextToColumns method command can make quick work of this.
Sub Convert_DMY()
With Worksheets("Sheet1") '<~~ set this properly!
With .Columns(1) '<~~ set this properly!
.TextToColumns Destination:=.Cells(1), _
DataType:=xlFixedWidth, _
FieldInfo:=Array(0, xlDMYFormat) 'xlDMYFormat = 4
End With
End With
End Sub
The xlDMYFormat
comes from the xlColumnDataType enumeration set.
Upvotes: 0
Reputation: 14764
If you want a true Excel date, do this:
=DATE(RIGHT(A1,4),MID(A1,3,2),LEFT(A1,2))
Upvotes: 2