Re: DATE field subtraction

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Ralph Graulich <maillist(at)shauny(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: DATE field subtraction
Date: 2002-08-19 11:38:35
Message-ID: 20020819213835.B23300@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 19, 2002 at 12:33:34PM +0200, Ralph Graulich wrote:
> Hi,
>
>
> I assume I am just to blind to find it in the documentation: I have a DATE
> field and want to subtract 4 weeks.
>
> SELECT [...]
> FROM table
> WHERE datefield >= '2002-08-19' - interval '4 weeks'

I'd do:

SELECT [...]
FROM table
WHERE datefield >= '2002-08-19'::date - 28;

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-08-19 13:07:55 Re: bytea operator bugs (was Re: [GENERAL] BYTEA, indexes
Previous Message Peter Gibbs 2002-08-19 10:49:50 Re: DATE field subtraction