Excel wont recognize date using openpyxl

Viewed 4550

I have a piece of code that converts a unix date to standard U.S. date format. It displays properly in excel, however excel doesn't recognize it as a date.

if str(startdate).isdigit():
    startdate = int(startdate)
    date = datetime.datetime.fromtimestamp(int(startdate)).strftime('%m/%d/%Y')
    ws4.cell(row=cell.row,column=2).value = date
    ws4.cell(row=cell.row,column=2).number_format = 'MM DD YYYY'

Any idea how to get excel to see this as a date rather than text?

1 Answers
Related