Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bgzjn-00027n-LC for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Sep 2016 19:39:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bgzjn-0002kZ-4Z for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Sep 2016 19:39:23 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bgzJR-0006gj-03 for pgsql-bugs@postgresql.org; Mon, 05 Sep 2016 19:12:09 +0000 Received: from gmmr2.centrum.cz ([2a00:da80:1:502::2]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bgzJN-0005wT-Ea for pgsql-bugs@postgresql.org; Mon, 05 Sep 2016 19:12:07 +0000 Received: from localhost (unknown [10.255.254.12]) by gmmr2.centrum.cz (Postfix) with ESMTP id DCFCA6001B64 for ; Mon, 5 Sep 2016 21:12:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=centrum.cz; s=mail; t=1473102720; bh=ADr3/xsx0hJqn+pHReqv2zwajm//B6AiM10+YUdv3Xs=; h=To:Subject:Date:From:Cc:References:In-Reply-To:From; b=kBTwSClwzZ0sZJ7i45a3RGVa3Lwb2JSZwgWcnXR6JQ27pWUBoDUfigYdlIA9oGyKe V7YudaRwWYv5jDFh9ESyw/1cSuIMp5X78VcY8dQw71kauHGAfF/vneFz50pwCpH2yH xzMSY2/E0UM8W1fdOJhjB5PXEsrnNXEKb0eTM68k= X-Envelope-To: pgsql-bugs@postgresql.org Received: by mail1014.cent (Postfix, from userid 33) id BBBD11C1E0; Mon, 5 Sep 2016 21:12:00 +0200 (CEST) To: =?utf-8?q?Greg_Stark?= , =?utf-8?q?Vik_Fearing?= Subject: =?utf-8?q?Re=3A_BUG_=2314313=3A_justify_interval_bug?= Received: from 86.49.75.134 (X-Forwarded-For: 86.49.75.134) by mail1014.centrum.cz (centrum.cz multimail) with HTTP Date: Mon, 05 Sep 2016 21:12:00 +0200 From: "Peterko" Cc: =?utf-8?q?PostgreSQL_Bugs?= References: <20160905163158.1413.60004@wrigleys.postgresql.org>, 0000000054f80018c1d40330db41 In-Reply-To: 0000000054f80018c1d40330db41 X-Mailer: Centrum Email 5.3 X-Priority: 3 X-Original-From: coolman.peto@centrum.cz MIME-Version: 1.0 Message-Id: <20160905211200.C0EA4356@centrum.cz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -4.4 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hi, my use case is that I need track event every 3 years and 10 months after previous event and keep in touch with object in upper limit for period of 3 years 10 months and 2 weeks.I performed comparison localtimestamp with the previous event date and if the interval was higher than interval of 3 years and 10 months and lower than interval of 3 years 10 months and 2 weeks, the the result is marked as target for next touch.   My question is, whether is it safe to subtract two timestamps and then compare interval without justify function with target interval (target interval is 3 years and 10 months, or 5 years and 10 months, or 7 years and 10 months, etc...). Or do I need recalculate the years of target interval to months? If I subtract two timestamps, is the internally stored correct number of days in interval value?   Best regards   Peter ______________________________________________________________ > Od: Greg Stark > Komu: Vik Fearing > Datum: 05.09.2016 20:29 > Předmět: Re: BUG #14313: justify interval bug > > CC: On Mon, Sep 5, 2016 at 6:59 PM, Vik Fearing wrote: > Your timestamp subtraction results in 7305 days.  The justify_interval > function, not knowing anything about where those days came from, will > use 30 days per month, giving you the result you see. Part of the story that's not apparent here is that intervals track months and days separately but don't track years separately. So the justified interval internally is actually 243 months, 15 days, and 0 seconds. The "20 years" is just part of the output format. The reason years aren't tracked separately is that they're always 12 months. So if you want an event in your calendar that occurs every year on the same date you can add an interval like '12 months' to it and it'll always add exactly a year and land on the same date regardless of the number of days in the year. -- greg -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs