In python, I am using the command
start = datetime.datetime.strptime(a, '%Y-%m-%d %H:%M:%S') and in Excel I have the date and time as 11/11/2005 12:00:00 AM. When I try to run the code, it is telling me that the time in excel does not match the code. How do I fix this?
Your string representation of your date is a little wrong.
import datetime a = "11/11/2005 12:00:00 AM" start = datetime.datetime.strptime(a, '%d/%m/%Y %H:%M:%S %p') print(start)
This is what I have managed to get:
With this code:
import xlsxwriter import datetime workbook = xlsxwriter.Workbook('myxls.xlsx') starting = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') worksheet = workbook.add_worksheet() worksheet.write('A1',starting)