Search Postgresql Archives

Re: Date addition/subtraction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux