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



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to