Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46980
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
|---|---|
| Subject | RE: How to increment date by week? |
| Date | 2013-06-05 01:52 +0300 |
| References | <b07dac48-1479-42cc-908c-21a3b2e14198@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2689.1370386330.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
> Date: Tue, 4 Jun 2013 14:31:07 -0700
> Subject: How to increment date by week?
> From: r90230@gmail.com
> To: python-list@python.org
>
> Starting on any day/date, I would like to create a one year list, by week (start date could be any day of week). Having a numerical week index in front of date, ie 1-52, would be a bonus.
> ie, 1. 6/4/2013
> 2. 6/11/2013
> 3. 6/18/2013....etc to # 52.
>
> And to save that result to a file.
> Moving from 2.7 to 3.3
> TIA
YAS:
import datetime
today = datetime.datetime.today()
week = datetime.timedelta(weeks=1)
f=open('output.txt','w')
for i in range(52):
f.write((today+i*week).strftime(str(i+1)+'. %Y-%m-%d\n'))
f.close()
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to increment date by week? PieGuy <r90230@gmail.com> - 2013-06-04 14:31 -0700 Re: How to increment date by week? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-04 22:44 +0100 Re: How to increment date by week? Tim Chase <python.list@tim.thechases.com> - 2013-06-04 16:50 -0500 Re: How to increment date by week? John Gordon <gordon@panix.com> - 2013-06-04 21:48 +0000 Re: How to increment date by week? Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-04 21:47 +0000 RE: How to increment date by week? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-05 01:52 +0300 Re: How to increment date by week? Skip Montanaro <skip@pobox.com> - 2013-06-04 20:17 -0500 Re: How to increment date by week? steve.ferg.bitbucket@gmail.com - 2013-06-04 20:43 -0700 Re: How to increment date by week? PieGuy <r90230@gmail.com> - 2013-06-05 09:39 -0700
csiph-web