Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'method,': 0.07; 'subject:number': 0.07; 'subject:How': 0.09; 'creighton': 0.09; 'cc:addr:python-list': 0.10; 'python': 0.11; 'wed,': 0.15; 'subject:between': 0.16; 'subject:dates': 0.16; 'subject:weeks': 0.16; 'wrote:': 0.16; 'laura': 0.18; '>>>': 0.20; 'cc:2**0': 0.21; 'cc:addr:python.org': 0.21; '2015': 0.23; 'module': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'data,': 0.27; 'message-id:@mail.gmail.com': 0.28; '25th': 0.29; 'url:mailman': 0.31; 'skip:d 20': 0.32; 'url:python': 0.33; 'weeks': 0.34; 'subject:?': 0.34; 'received:google.com': 0.34; 'gives': 0.35; 'there,': 0.35; 'url:listinfo': 0.35; 'but': 0.36; 'url:org': 0.36; 'there': 0.36; 'monday,': 0.36; 'url:library': 0.36; 'subject:: ': 0.37; 'end': 0.39; 'pm,': 0.39; 'url:2': 0.39; 'whatever': 0.39; 'url:docs': 0.39; 'sure': 0.40; 'your': 0.60; 'skip:n 10': 0.63; 'saturday': 0.66; 'thursday': 0.66; 'answer.': 0.72; '9th': 0.84; 'june,': 0.84; 'to:none': 0.90; 'joel': 0.91; 'subject:find': 0.91 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:cc :content-type; bh=SdKshYE3p1b7SVm88B8XWHkE8lR6uhOX9Iv6H2CTUG8=; b=EuDP1E50ylq3loo92eP2ynPTkQJi2KLHV1h3vAbbMCPFeFXlVS2KaGfWCHuhG9+DbF NZ+davueW9KPvU4s6BZilteRDLMKPhbnILuLYd0EsFidhz3UPORazseErEEWcLfa/ANG NfwNV0IHLEn2R26skw7oGhAPFGep+F+8DORMole6j+3p6MImaxvt9D/tzqTcoSp7PlNa SFcCFqExv5uDadGgiafvx86QyJRJ2BK2mgdtQR5tg2AmsKG5BRujRmMGGrLOwD4DcMt6 xzhfwCs9Utnd55h3wHvmdNll6Zy3N/K69QRiyDMcI7agcRERVI17Dw5ni69zz1jCHaIQ KD3w== MIME-Version: 1.0 X-Received: by 10.107.168.82 with SMTP id r79mr5996218ioe.4.1433959666835; Wed, 10 Jun 2015 11:07:46 -0700 (PDT) In-Reply-To: <201506101750.t5AHoSSu008696@fido.openend.se> References: <877frbwjik.fsf@elektro.pacujo.net> <201506101750.t5AHoSSu008696@fido.openend.se> Date: Wed, 10 Jun 2015 14:07:46 -0400 Subject: Re: How to find number of whole weeks between dates? From: Joel Goldstick Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433959670 news.xs4all.nl 2859 [2001:888:2000:d::a6]:39970 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92419 On Wed, Jun 10, 2015 at 1:50 PM, Laura Creighton 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