When I load an Excel file as text, dates are loaded as an integer (for example 42705). Converting them to R dates is easy, but I often forget the value I should use in the argument origin to actually make the conversion. This post is to keep the reminder at hand.
Excel Dates

Excel meme about the half empty glass
You know, Excel is a meme. And the issue it has with dates is not minor. For that reason I often find myself loading Excel files as text:
dt = readxl::read_excel("path_to_file.xlsx", col_types = "text")
The problem when I do that is that actual date columns are loaded as an integer number, Excel’s internal representation of dates. Converting them is straightforward:
dt$date_column = as.Date(as.numeric(dt$date_column), origin = "1899-12-30")
My problem is remembering “1899-12-30”.
Why 1899? Well, that makes some sense. But what I can’t still process is December 30th instead of December 31st (or even better, January 1st, 1900).
Excel’s particularities, I imagine.