Re: Date addition/subtraction - Mailing list pgsql-general

From Ragnar Hafstað
Subject Re: Date addition/subtraction
Date
Msg-id 1115143710.5853.48.camel@localhost.localdomain
Whole thread Raw
In response to Date addition/subtraction  ("Craig Bryden" <postgresql@bryden.co.za>)
List pgsql-general
On Tue, 2005-05-03 at 19:32 +0200, Craig Bryden wrote:
>
> How in postgres can I do date/time subtraction or addition.
> e.g. If I want to get today's date - 30 days? or current_timestamp - 1 hour?

easier than you think

select current_timestamp - interval '1 hour';
select current_date -interval '30 days';          -- timestamp
select current_date + interval '1 week';          -- timestamp
select date (current_date + interval '1 week');   -- date

see:
http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html

gnari



pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Date addition/subtraction
Next
From: Ragnar Hafstað
Date:
Subject: Re: Sorting by constant values