Help converting character to date

I'm struggling converting a charter variable to a date variable. For example

tibble(date = c("31jan2003", "28feb2003"))

I tried the following:

tibble(date = c("31jan2003", "28feb2003")) %>% lubridate::dmy(date, format = "%d%b%Y")

What am I missing?

Thanks!

You cannot pass the whole data frame to dmy(). Try putting dmy() inside of the mutate function from dplyr.

tibble(date = c("31jan2003", "28feb2003")) %>% 
  mutate(date = lubridate::dmy(date))
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.