Convert Excel To Csv - Properly Convert Date Fields
So, I now have my Excel2CSV function working, but encountered another problem wherein the Date Fields in my Excel File ('Date Opened', 'Date Closed') which are formatted as Date in
Solution 1:
To convert from the date number to a Python datetime use the following formula:
dt = datetime.datetime(1899, 12, 30) + datetime.timedelta(days=num)
Once you've done that you can convert it to the default format with str(dt) or specify your own format with dt.strftime(format). See the datetime documentation
Post a Comment for "Convert Excel To Csv - Properly Convert Date Fields"