Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

date from day (count) of year

13 views
Skip to first unread message

Vincent Davis

unread,
Apr 24, 2015, 9:43:58 AM4/24/15
to pytho...@python.org
How does one get the date given the day of a year.

>>> dt.datetime.now().timetuple().tm_yday

114

How would I get the Date of the 114 day of 2014?

Vincent Davis

Ian Kelly

unread,
Apr 24, 2015, 10:02:14 AM4/24/15
to Python

You could use a timedelta:

>>> dt.date(2014, 1, 1) + dt.timedelta(114 - 1)
datetime.date(2014, 4, 24)

Vincent Davis

unread,
Apr 24, 2015, 10:24:17 AM4/24/15
to Ian Kelly, Python

On Fri, Apr 24, 2015 at 8:01 AM, Ian Kelly <ian.g...@gmail.com> wrote:

>>> dt.date(2014, 1, 1) + dt.timedelta(114 - 1)
datetime.date(2014, 4, 24)


​Thanks!​
Vincent Davis

0 new messages