Separating columns

I need help in separating columns as shown below:

year22$date <- as.Date(year22$started_at)
year22$year <- format(as.Date(year22$date), "%Y")
year22$month <- format(as.Date(year22$date), "%m")
year22$weekday <- wday(year22$date, label=TRUE)
year22$hour <- format(year22$started_at, format = "%H")

year22$ride_length <- (year22$ended_at - year22$started_at)
year22 <- year22 %>%
filter(ride_length > 0)

It keeps giving my errors as shown below:

Error in charToDate(x): character string is not in a standard unambiguous format

  1. as.Date(year22$started_at)
  2. as.Date.character(year22$started_at)
  3. charToDate(x)
  4. stop("character string is not in a standard unambiguous format")

Appreciated in advance for your help.

The error is caused by the attempted transformation


because you are not telling as.Date() what the format is of the column started_at. Please post an example of what started_at looks like, making sure it is clear what represents the day and the month, and someone can help you set the format code of as.Date().