More on Python Dates, adding time with a datetime.timedelta

I needed a date 2 weeks in the future. I needed it quickly. After blogging about Python dates, I thought I had a clue how to do it. To my relief the first attempted path of least resistance just worked! Here it is:


>>> from datetime import date, timedelta
>>> today = date.today()
>>> two_weeks = timedelta(days=14)
>>> two_weeks_time = today + two_weeks
>>> today
datetime.date(2006, 12, 6)
>>> two_weeks_time
datetime.date(2006, 12, 20)
>>>


This was used to automatically populate a column in an an old database: which wanted to be an expected_date = order_date + two_weeks.

Popular posts from this blog

PyGTK, Py2exe, and Inno setup for single-file Windows installers

Kiwi proxy widgets, a common widget API

Using threads in PyGTK