Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbTCN-0007iE-RA for pgsql-sql@arkaria.postgresql.org; Wed, 30 Oct 2013 10:40:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VbTCN-0006z6-BN for pgsql-sql@arkaria.postgresql.org; Wed, 30 Oct 2013 10:40:27 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbTCM-0006z0-Js for pgsql-sql@postgresql.org; Wed, 30 Oct 2013 10:40:26 +0000 Received: from teak.britvault.co.uk ([78.33.153.148]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VbTCE-0007Ok-Dk for pgsql-sql@postgresql.org; Wed, 30 Oct 2013 10:40:25 +0000 Received: by teak.britvault.co.uk (Postfix, from userid 1970) id 3d8mQS168czBCD; Wed, 30 Oct 2013 10:40:16 +0000 (GMT) Date: Wed, 30 Oct 2013 10:40:15 +0000 To: pgsql-sql@postgresql.org Subject: Re: Number of days in a tstzrange? Message-ID: <20131030104015.GA12587@teak.britvault.co.uk> References: <20131024204638.GA31094@teak.britvault.co.uk> <219E3855-325F-4B55-A23B-DA014FBDA2BF@excoventures.com> <20131029113450.GA26067@teak.britvault.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131029113450.GA26067@teak.britvault.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) From: skinner@britvault.co.uk (Craig R. Skinner) X-Pg-Spam-Score: 0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 2013-10-29 Tue 11:34 AM |, Craig R. Skinner wrote: > > -- if a subscription is ceased same day it's started, > -- that day is still chargable, so bump it > IF billable_days < 1 > THEN > billable_days := 1; > END IF; > ... > ... > This is more accurate: -- If a subscription billing_period ends part way through a day, IF upper(billable_item.billable_period)::time <> time 'allballs' THEN -- That partial day is still chargable, so bump it billable_days := billable_days + 1; END IF; -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql