how to change text format date to date format in excel?

Viewed 18

my data has date in below format I have to clean it and make it as correct date format. Tried format cell didnt work, used R didnt work

Date Correct date
Dec 26, 2012 26-12-2012
Jan 2, 2012
Jan 16, 2012
1 Answers

We can use the format - %b %d, %Y to convert to Date class and then reconvert to another format %d-%m-%Y (as it is different from the default format used in Date class - %Y-%m-%d) which would be a character class

df1$Correctdate <- format(as.Date(df1$Date, '%b %d, %Y'), '%d-%m-%Y')

-output

df1
#          Date Correctdate
#1 Dec 26, 2012  26-12-2012
#2  Jan 2, 2012  02-01-2012
#3 Jan 16, 2012  16-01-2012

data

df1 <- data.frame(Date = c("Dec 26, 2012", "Jan 2, 2012", "Jan 16, 2012"))
Related