How to convert (YY,MM,DD,HH,MM,SS) to the Excel "serial" datetime number.
Example: 12/23/2017 10:00:00 PM to 43092.91667
Below converts the date only, but I need to add the timestamp as well:
def convertDateToExcel(day, month, year) :
offset = 693594
itime = date(year,month,day)
n = itime.toordinal()
return (n - offset)
A prime example of me overthinking the problem :-)
The obvious answer:
def convertDateToExcel(year, month, day, hour, minute, second) :
offset = 693594
itime = date(year,month,day)
n = itime.toordinal()
return (n - offset + (60*60*hour + 60*minute + second)/(24*60*60))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.