I am pulling a date in from an excel file and it comes in as a string. When I export the date to a new excel sheet, I am not able to perform math functions on it i.e. subtract the date cell from another date cell. I am trying to convert the incoming date to something I can work with on the new excel sheet and am running into trouble.
I have tried several things, and this code is my latest failed attempt. The ['F12'] value is a date that looks like Mar 7, 2024. I think the problem is the Mar in the output, but I could be wrong.
date = workbook.active['F12'].value
date_fixed = datetime.strptime(date, '%Y-%m-%d')
You can use the documentation's table at the end of the page strptime to adapt the format to your case: