I'm trying to save an excel file with the date and time within the filename. I do:
from time import gmtime, strftime
dtnow = str(strftime("%Y-%m-%d %H:%M", gmtime()))
wb_name = '{0}--template.xls'.format(dtnow)
dest = ('\\').join(source.split('\\')[:-1])
# With the dest variable I'm just finding the destination folder to save in from a source variable that I have from before.
wb.save(os.path.join(dest,wb_name))
When I save that, I get this as the saved file:
2018-02-13 14
However if I remove the date and time variable completely and just have
wb_name = 'template.xls'
wb.save(os.path.join(dest,wb_name))
I get a proper excel file with the extension and everything's fine. I think the colon is causing some sort of error. I'm not sure. Also, after saving, the file shows to be 0 bytes, while the template.xls that saves properly is the correct file size. Why can't I save the excel file with the datetime and have the extension included?