Changing a string date to correct datetime format

I have an excel file with several date columns that are formatted ex. "4/6/2023 10:35:47 AM

When I use readxl::read_xlsx the column comes in as a string column that look like ex. "45022.358182870368"

How can I get this formatted in a way that I can easily arrange or summarize to see the earliest and latest dates in each column?


Edit: Sorry, I did not read very carefully. The problem is the Excel date format, not converting characters to datetime in R. Try this function from the openxlsx package:


Original post:

Is that April 6, 2023 or June 4, 2023, that is, is it month/day/year or day/month/year?
You can use the lubridate package, which is part of the tidyverse, to convert to POSIXct datetime.
Assuming it is April 6, use mdy_hms("4/6/2023 10:35:47 AM")

1 Like

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.