I am playing around with the datetime API and i am trying to add a full year to today’s date. For some reason the code is throwing an error. This is what my code looks like
from datetime import datetime, timedelta
print(datetime.today().date() + timedelta(months=12))
This is giving me this error. The error is
TypeError: 'months' is an invalid keyword argument for __new__()
I don’t know if i am missing something in this code.
I have tried just initializing timedelta in another variable without any arguments and it works. But when i add argument thats when it breaks. This is what i tried.
test = timedelta()
dark dayone is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.