date from day (count) of year

Ian Kelly ian.g.kelly at gmail.com
Fri Apr 24 10:01:54 EDT 2015


On Apr 24, 2015 7:45 AM, "Vincent Davis" <vincent at vincentdavis.net> wrote:
>
> 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?

You could use a timedelta:

>>> dt.date(2014, 1, 1) + dt.timedelta(114 - 1)
datetime.date(2014, 4, 24)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150424/ab3b461d/attachment.html>


More information about the Python-list mailing list