I am trying to format a date from a character of form mmm dd, yyyy
I tried :
date1 <- "Dec 05, 2016"
date2 <- format(date1, format="%d %B %Y")
class(date2)
date2
but this does not work. Thank you for any help.
I then tried as suggested:
date1 <- "Dec 05, 2016"
date2 <- format(as.Date(date1, "%b %d, %Y"), "%d %B %Y")
date2 <- as.Date(date2)
class(date2)
date2
but this still did not covert to the class date but was class: character
This seems to work ref:Convert character to Date in R
library(lubridate)
date1 <- "Dec 05, 2016"
date2 <- mdy(date1)
class(date2)
date2