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: Daniel <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 17:01:59
Message-ID: 13182.1215018119@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
Daniel <psql-novice(at)netzach(dot)co(dot)il> writes:
>> If that doesn't satisfy your requirements, you need to be more clear
>> about what they are.

> Apologies for the lack of clarity.
> Try repeat_frequency='1 month'

Ah.  Well, with something like that, you really can't speak in terms of
modulo, because months aren't all the same length.  I'd be inclined to
solve this with a small plpgsql function, along the lines of

	curdate := start_date;
	while curdate < test_date loop
		curdate := curdate + repeat_interval;
	end loop;
	return (curdate = test_date);

Kinda grotty but there probably isn't any cleaner solution that really
works for arbitrary intervals.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Alan HodgsonDate: 2008-07-02 17:02:48
Subject: Re: Concurrent COPY commands
Previous:From: Stephan SzaboDate: 2008-07-02 17:00:51
Subject: Re: encoding problem when creating a database

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