How do I calculate the date six months from the current date using the datetime Python module?

PythonServer Side ProgrammingProgramming

You can use the timedelta function from datetime module to achieve this. For example,

>>> import datetime
>>> today = datetime.date.today()
>>> print today
2017-09-12
>>> six_months_later = today + datetime.timedelta(30*6)
>>> print six_months_later
2018-03-11
raja
Published on 21-Dec-2017 07:19:35
Advertisements