Re: Date Math

From: aklaver(at)comcast(dot)net (Adrian Klaver)
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Date Math
Date: 2007-05-07 17:50:12
Message-ID: 050720071750.8431.463F66D400082135000020EF22073000339D0A900E04050E@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-------------- Original message ----------------------
From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
> On Mon, 7 May 2007, aklaver(at)comcast(dot)net wrote:
>
> > test=> select '01/01/04'::date +interval '3 year',current_date + interval
> > '2 month';
> > ?column? | ?column?
> > ---------------------+---------------------
> > 2007-01-01 00:00:00 | 2007-07-07 00:00:00
> > (1 row)
>
> Adrian,
>
> I think so, but without explicit strings. The dates and intervals are in
> the table, and I want the rows that meet the specified conditions.
>
> Is the following closer to correct?
>
> SELECT ... FROM Permits
> WHERE (date_issued::DATE + INTERVAL term)
> < (CURRENT_DATE + INTERVAL process_time + INTERVAL '2 week')
>
> Thanks,
>
> Rich

If term and process_time are stored as intervals then it will work. Also if they are stored as
INTERVALS you can do CURRENT_DATE+process_time. In other words not have to declare the
INTERVAL . Is date_issued stored as a date? If so it would not need to be cast.
--
Adrian Klaver
aklaver(at)comcast(dot)net

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2007-05-07 17:56:18 Re: Date Math
Previous Message Martin Gainty 2007-05-07 17:47:53 Re: Postgre Sql 7.3 connection problem