Split time from datetime

How can I split "16/03/2021 08:32" into time only with R?

tried using
format(as.POSIXct(bike_rides1$started_at), format = "%H:%M")
and it returned 00:00,
I also tried format(as.POSIXct(bike_rides1$started_at), format = "%H:%M:%S")
and it returned 00:00:00 as well.

Hi @Olufunke

It's because you didn't parse the date column properly, you need to indicate the date format in as.POSIXct.

The code below should work.

format(as.POSIXct(bike_rides1$started_at, format = "%d/%m/%Y %H:%M"), format = "%H:%M")

Thank you, it worked

This topic was automatically closed 21 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.