Home » excel » Change date in excel

Change date in excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am trying to change the date format of my cells in excel to another date format. Currently it is in this format: apr, 10, 2017 01:58:24 PM. I would like to have it in a normal format like dd-mm-yyyy without the time, but I can not get it to work with the formatting in excel.

Thanks in advance,
Kester

How to&Answers:

You could use this:

=(MID(A2,FIND(",",A2)+2,FIND(",",SUBSTITUTE(A2,",","@",1))-FIND(",",A2)-2)&"-"&LEFT(A2,FIND(",",A2)-1)&"-"&MID(A2,FIND(",",SUBSTITUTE(A2,",","@",1))+2,LEN(A2)))*1

Which is basically a bit of string manipulation (and some substitution of , to @ to help) to put it in the generic format ‘d-m-y h:m:s t’, which excel understands, then multiply the string by 1 to force into a number (in this case 42835.58222); which you only have to format as date (important!):

enter image description here


Edit: Per comments, the first comma doesn’t actually exist, so the revised formula:

=(MID(A2,FIND(" ",A2)+1,FIND(",",A2)-FIND(" ",A2)-1)&"-"&LEFT(A2,FIND(" ",A2)-1)&"-"&MID(A2,FIND(",",A2)+2,LEN(A2)))*1

Answer:

With data in A1, in B1 enter:

=DATE(MID(A1,10,4),MATCH(LEFT(A1,3),{"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"},0),MID(A1,6,2))

and apply desired formatting:

enter image description here

(this results in a genuine Excel date that can be used in sorts, calculations, etc.)
(this assumes that the day field is always two digits)
(if your month list is in a language other than English, edit the month list)