Hello,

I have to convert a MATLAB's datenum to Python's datetime. The following code is as below:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
import datetime
matlab_datenum = 63650571169.50261
python_datetime = datetime.date.fromordinal(int(matlab_datenum)) + datetime.timedelta(days=matlab_datenum%1) -  datetime.timedelta(days = 366)
print (matlab_datenum)
63650571169.50261 is a datenum that represents a date plus a time for example 2010-11-04 00:03:50.209589

The above code generates this error:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
OverflowError: Python int too large to convert to C long
The above code, is it correct ? how can i obtain a date plus a time ?

Thank you for your help,