Skip site navigation (1) Skip section navigation (2)

Re: Calculating repeating events - functionality lost with the demise of tinterval ?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Netzach <psql-novice(at)netzach(dot)co(dot)il>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Calculating repeating events - functionality lost with the demise of tinterval ?
Date: 2008-07-02 14:57:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Netzach <psql-novice(at)netzach(dot)co(dot)il> writes:
> I need to know whether a repeating event occurs or not on a particular
> day. I currently have the following information:<br>
> <br>
> date of first occurrence (date)<br>
> repeat frequency (interval)<br>
> date to check (date)<br>
> <br>
> My instinct says that I should be using a mod here to calculate whether
> the remainder is zero when the difference between the two times is
> divided by the repeat frequency. Unfortunately this is not possible
> since as far as I am aware intervals only specify a time length and not
> two dates.

Huh?  If you only need this good to day precision, as your reference to
dates suggests, then just subtract the two dates (which will give an
integer number of days) and modulo by the repeat frequency (also given
as an integer number of days).

If that doesn't satisfy your requirements, you need to be more clear
about what they are.

> When searching I discovered tinterval which appears to do
> what I would want, and was surprised to discover that it is not
> supported in my postgres install because it is too _new_ !?! (PG 8.1).<br>

Actually tinterval is ancient and deprecated.  But I don't see how
it would apply to your problem as stated.

			regards, tom lane

In response to


pgsql-novice by date

Next:From: Tom LaneDate: 2008-07-02 15:25:57
Subject: Re: Table exists but can't drop.
Previous:From: A BDate: 2008-07-02 14:55:35
Subject: Re: encoding problem when creating a database

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group