I have the below code which works out the date 6 months ago from todays date.
import datetime
from dateutil.relativedelta import relativedelta
from datetime import date
six_months = date.today() + relativedelta(months=-6)
However I would like six_months to be in "%Y%m%d" format.
Thank you for your help.
You're looking for strftime
.
six_months.strftime('%Y%m%d')
This should do the job for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With