Here is what occurred to me:
select date (date '0000-12-31' + interval '733973 days'); >> "2010-07-20"
or
select date (date '0000-12-31' + interval '1 days' * 733973); >> "2010-07-20"
It simply adds the number of days to the date 0000-12-31 . It does not use date 0001-01-01 , because datetime.toordinal() is defined as 1 for this date, therefore, the offset is -1. A.
From python docs
date.fromordinal (ordinal)
Return the date corresponding to the pro-reptic Gregorian order, where on January 1 of year 1 has serial number 1 ...
Edit:
If the date 0000-31-12 not recognized as a valid date, you can easily change the instruction to something like:
select date (date '0001-01-01' + interval '733973 days' - interval '1 day');
or
select date (date '0001-01-01' + (interval '1 days' * (733973 - 1)));
source share