Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #92419
| References | <a2056385-f99b-4691-9a33-5def63216e9c@googlegroups.com> <marko@pacujo.net> <877frbwjik.fsf@elektro.pacujo.net> <201506101750.t5AHoSSu008696@fido.openend.se> |
|---|---|
| Date | 2015-06-10 14:07 -0400 |
| Subject | Re: How to find number of whole weeks between dates? |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.355.1433959670.13271.python-list@python.org> (permalink) |
On Wed, Jun 10, 2015 at 1:50 PM, Laura Creighton <lac@openend.se> wrote:
> In a message of Wed, 10 Jun 2015 20:38:59 +0300, Marko Rauhamaa writes:
>>Divide the number by 7 and you have your answer.
>>
>
> I am not sure that is what he wants -- If he gives us a start of Tuesday the
> 9th of June 2015 (yesterday) and an end of Thursday the 25th of June, that's
> 16 days. But there is only one Monday-Friday week in there, the 14th-19th.
>
> So if the OP wants an answer of 1 for such data, he may be interested in
> the python calendar module https://docs.python.org/2/library/calendar.html
>
> Laura
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
Find the number of weeks with the above method, then
>>> import datetime
end_date = datetime.datetime(2012, 3, 23) // whatever your end date is
if end_date.weekday() != 5:
number_of_complete _weeks -= 1
weekday returns 0 for monday, so 5 for Saturday
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to find number of whole weeks between dates? Sebastian M Cheung <minscheung@googlemail.com> - 2015-06-10 10:05 -0700
Re: How to find number of whole weeks between dates? Marko Rauhamaa <marko@pacujo.net> - 2015-06-10 20:38 +0300
Re: How to find number of whole weeks between dates? Marko Rauhamaa <marko@pacujo.net> - 2015-06-10 20:43 +0300
Re: How to find number of whole weeks between dates? Laura Creighton <lac@openend.se> - 2015-06-10 19:50 +0200
Re: How to find number of whole weeks between dates? Joel Goldstick <joel.goldstick@gmail.com> - 2015-06-10 14:07 -0400
Re: How to find number of whole weeks between dates? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-10 20:48 +0100
Re: How to find number of whole weeks between dates? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-10 11:42 -0600
Re: How to find number of whole weeks between dates? Sebastian M Cheung <minscheung@googlemail.com> - 2015-06-10 13:11 -0700
Re: How to find number of whole weeks between dates? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-10 21:26 +0100
Re: How to find number of whole weeks between dates? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-10 14:33 -0600
Re: How to find number of whole weeks between dates? Michael Torrie <torriem@gmail.com> - 2015-06-10 21:19 -0600
Re: How to find number of whole weeks between dates? Chris Angelico <rosuav@gmail.com> - 2015-06-11 13:36 +1000
Re: How to find number of whole weeks between dates? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-10 21:45 -0600
Re: How to find number of whole weeks between dates? Sebastian M Cheung <minscheung@googlemail.com> - 2015-06-10 19:01 -0700
Re: How to find number of whole weeks between dates? Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-10 21:35 -0600
csiph-web