Converting dates to excel compatible

I use dates in julia, then I convert them in days in the following fashion

# Convert a date to a number of days
date = Date(2023, 6, 7)
days = Dates.days(date)

I then look up the dates with other values to create an array that I want to export in excel. My issue is that dates are then in the julia format above (i.e. in actual number of dates)

Is there a way to convert days back into a date that I can use in excel?

There are apparently two formats, do you know which Excel format?

So the Dates.days function seems to reference to year 1, January 1. Microsoft seems to use the 1904 system? The difference in days is then:

julia> Dates.days(Date("0001-01-01"))

julia> Dates.days(Date("1904-01-01"))

Newer versions of excel use 1900 as a base year. I can do the difference in dates then and see. I was wondering if there’s a more immediate way to work with dates in julia. Coming from matlab I never did bother that much working with arrays of time which I could easily use in excel.

What do you mean by “more immediate way”? Why not just write the Dates to Excel?

julia> using XLSX, Dates

julia> XLSX.writetable("out.xlsx", (x = Date(2010):Year(1):Date(2019), y = rand(10)))



Or is your question about how to get the date back from 738678 in Julia?

julia> Dates.epochdays2date(738678) + Year(1)