As you can guess, there are functions for all possible date formats. For example, you would use the following functions:
dmy_hms() to parse a date time format with its parts: year, month, day, hour, minute, and second.
dmy() to parse only dates.
mdy_h() to parse only dates and hours.
You may check out all formats at the
lubridate's reference page.
We can also extract only the date from the
departure_datetime column. To do this, we need the
trucks$departure_date <- date(trucks$departure_datetime)
The function will drop the hours, minutes, and seconds of the date and it will only return the date.