On 2013-10-24 Thu 17:00 PM |, Jonathan S. Katz wrote:
>
> Yes, you would have to call lower() and upper() to accomplish that.
>
Here's my final solution inside a function's CUSROR LOOP:
DECLAREbillable_days integer;.....
BEGIN......SELECT -- cast boundries to date -- date - date = integer
upper(billable_item.billable_period)::date- lower(billable_item.billable_period)::dateINTO billable_days;
-- if a subscription is ceased same day it's started,-- that day is still chargable, so bump itIF billable_days < 1THEN
billable_days := 1;END IF;......
Thanks,
--
Craig Skinner | http://twitter.com/Craig_Skinner | http://linkd.in/yGqkv7