‘str’ object has no attribute ‘weekday’ Convert date to a string

date = datetime.datetime.today()
shift = datetime.timedelta(max(1,(date.weekday()+6)%7 - 3))

new_mail.Subject = 'XXXXXXX as of ' + (date - shift).strftime('%Y-%m-%d')

The problem is that you convert date to string initially and therefore cannot perform date arithmetic on it from there on.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top