Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46974
| Date | 2013-06-04 16:50 -0500 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: How to increment date by week? |
| References | <b07dac48-1479-42cc-908c-21a3b2e14198@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2684.1370382496.3114.python-list@python.org> (permalink) |
On 2013-06-04 14:31, PieGuy wrote:
> 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.
import datetime
start = datetime.date.today()
for i in range(53):
dt = start + datetime.timedelta(days=7*i)
result = "%i. %s" % (
i+1,
dt.strftime('%m/%d/%Y')
)
do_something_with(result)
-tkc
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