Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.159 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.69; '*S*': 0.00; '24,': 0.16; '7:45': 0.16; 'wrote:': 0.18; '>>>': 0.22; '>>>': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'subject:) ': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:from': 0.34; 'could': 0.34; 'subject: (': 0.35; 'received:google.com': 0.35; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'year.': 0.61; 'subject:day': 0.69; 'day': 0.76; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=+Ryn5rqH7g5WJ3swxGTL3Dqy2CBP3kgAIf0IDwvLzSM=; b=1AJBh/7Sr+J74gDXvd/QXZgRFT0BgLZymFC0ES7DXrep7d95LIrBmwlxuTbXjbuCoe yi1mG6DFVrxOPoVGsqZN4kFqeTbUHefcKsrPfNwIMrevqy0bE6voyDFijs5ZFAgPyjv4 XUSvdnSFeJ7sJJXljl0v4UbYmCw/COos/fDzMheL+9APT5yabzWcLkt4QrSWzIkKx/Te VrCbHumJHu8lBcXNT46G306wkV8qEoDXVuJPb4wXsBBkCNJCush93uCT16Yg+pBx9N+s /Ec4snv3FoglB5cHa0QY6yxaWxShmwiXzvUSD0Qoifs5nS3OSp2HQ3pdZLvX2WxrPaMq xYyQ== MIME-Version: 1.0 X-Received: by 10.107.12.158 with SMTP id 30mr10809734iom.61.1429884114981; Fri, 24 Apr 2015 07:01:54 -0700 (PDT) In-Reply-To: References: Date: Fri, 24 Apr 2015 08:01:54 -0600 Subject: Re: date from day (count) of year From: Ian Kelly To: Python Content-Type: multipart/alternative; boundary=001a113dc818beab9e051478d6cf X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1429884123 news.xs4all.nl 2885 [2001:888:2000:d::a6]:40241 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89367 --001a113dc818beab9e051478d6cf Content-Type: text/plain; charset=UTF-8 On Apr 24, 2015 7:45 AM, "Vincent Davis" 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) --001a113dc818beab9e051478d6cf Content-Type: text/html; charset=UTF-8

On Apr 24, 2015 7:45 AM, "Vincent Davis" <vincent@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)

--001a113dc818beab9e051478d6cf--