I have an excel sheet created by a 3rd party program.
One of the columns has dates in this format: \"Jan 19, 2015 03:00:00 PM\"
I would like these dates to appea
The only way to solve this is to:
upload the Excel sheet to Google Drive. On Google Drive do this:
click to open the file with Google spreadsheet
Once it has opened as a Google spreadsheet, select the entire column with dates.
select the format type to Date (you can choose any format of date you want).
Download the Google spreadsheet as .xlsx. All the contents of the column are now dates
The following worked for me:
Now you got date values
While you didn't tag VBA as a possible solution, you may be able to use what some feel is a VBA shortcoming to your advantage; that being VBA heavily defaulted to North American regional settings unless explicitly told to use another.
Tap Alt+F11 and when the VBE opens, immediately use the pull down menus to Insert ► Module (Alt+I,M). Paste the following into the pane titles something like Book1 - Module1 (Code).
Sub mdy_2_dmy_by_Sel()
Dim rDT As Range
With Selection
.Replace what:=Chr(160), replacement:=Chr(32), lookat:=xlPart
.TextToColumns Destination:=.Cells(1, 1), DataType:=xlFixedWidth, FieldInfo:=Array(0, 1)
For Each rDT In .Cells
rDT = CDate(rDT.Value2)
Next rDT
.NumberFormat = "dd/mm/yyyy"
End With
End Sub
Tap Alt+Q to return to your worksheet. Select all of the dates (just the dates, not the whole column) and tap Alt+F8 to Run the macro.
Note that both date and time are preserved. Change the cell number format if you wish to see the underlying times as well as the dates.
My solution to a similar problem with Date formatting was solved by:
QED.
The problem sheet contained Date data that I wanted to read as 07/21/2017 that would not display anything other than 42937. The first thing I did was to close Excel and re-launch it. More tries followed. I gave up on my own solutions. I tried a few online suggestions. I then made one more attempt and - Walla - the above three steps fixed the problem. As to why the problem existed? It obviously had something to do with "the" sheet. Go figure!
For me to believe is insufficient for you to know - rodalsa.
Given your regional settings (UK), and the inability of formatting to change the date, your date-time string is text. The following formula will convert the date part to a "real" date, and you can then apply the formatting you wish:
=DATE(MID(A1,FIND(",",A1)+1,5),MATCH(LEFT(A1,3),{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0),MID(SUBSTITUTE(A1,","," "),5,5))
Might be able to simplify a bit with more information as to the input format, but the above should work fine. Also, if you need to retain the Time portion, merely append:
+RIGHT(A1,11)
to the above formula.
Similar way as ron rosefield but a little bit simplified.
=DATE(RIGHT(A1,4),MATCH(MID(A1,4,2),{"01";"02";"03";"04";"05";"06";"07";"08";"09";"10";"11";"12"},0),LEFT(A1,2))