I am converting from chr to POSIXct formatted as "%Y-%m-%d %H:%M:%S however, some of the times in the dataset do not have the seconds portion (%S) so when I convert to DateTime the times without the seconds are returned as empty cells - NA How do I make sure this does not happen. I want them all returned as DateTime regardless of if some time portions are missing or not?
The date-times that are in this format ("%Y-%m-%d %H:%M:%S")are returned correctly as POSIXct
But the date-times that are in this format ("%Y-%m-%d %H:%M") are returned as NA
This is the code is used for the conversion
trips$ended_at <- as.POSIXct(trips$ended_at, format = "%Y-%m-%d %H:%M:%S")
It is a huge dataset with over a million entries so i don't even know which datetimes don't have the seconds portion.
Is there a way that those without the seconds' portion can just have zeroes and the end?
for example, 2020-29-04 01:57 will be returned as 2020-29-04 01:57:00 when converted to POSIXct
Please help!