'Messy dates after importing from Excel into R

I have trouble reading in a date column in the correct format after importing an excel file.

If I format the Date column to character, some dates appear messy - like 44655, 44565, 31/03/2022, 30/03/2022...

when the Date column is formatted as character

However, if I format the Date column as a date, there are some NA values.

when the Date column formatted in date

What is the problem? How can I reformat all values in the Date column in d/m/y?



Solution 1:[1]

This normally occurs if you have entered dates into your excel spreadsheet in multiple formats. I suspect on your excel spreadsheet, sometimes you have the date formatted as a date, and other times, the date is formatted as text. In my experience, its simplest when you have the date entered in excel as text.

If you go in excel, and change the column format to text, you will see the entries that are mixed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joe Erinjeri