I must have the current year and month in datetime.
I use this:
datem = datetime.today().strftime(\"%Y-%m\") datem = datetime.strptime(datem, \"%Y-%m
You can write the accepted answer as a one-liner using date.replace:
datem = datetime.today().replace(day=1)