DATE field subtraction

Started by Ralph Graulichover 23 years ago3 messagesgeneral
Jump to latest
#1Ralph Graulich
maillist@shauny.de

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 ...

#2Peter Gibbs
peter@emkel.co.za
In reply to: Ralph Graulich (#1)
Re: DATE field subtraction

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

#3Martijn van Oosterhout
kleptog@svana.org
In reply to: Ralph Graulich (#1)
Re: DATE field subtraction

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/

Show quoted text

There are 10 kinds of people in the world, those that can do binary
arithmetic and those that can't.