Обсуждение: DATE field subtraction

Поиск
Список
Период
Сортировка

DATE field subtraction

От
Ralph Graulich
Дата:
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'


Kind regards
... Ralph ...



Re: DATE field subtraction

От
"Peter Gibbs"
Дата:
Ralph Graulich wrote:
> SELECT [...]
> FROM table
> WHERE datefield >= '2002-08-19' - interval '4 weeks'

There are probably shorter forms, but the full version would be:
  '2002-08-19'::date - '4 weeks'::interval
--
Peter Gibbs
EmKel Systems



Re: DATE field subtraction

От
Martijn van Oosterhout
Дата:
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@svana.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.