Re: DATE_ADD, DATE_SUB, ETC - Mailing list pgsql-novice

From Jason Earl
Subject Re: DATE_ADD, DATE_SUB, ETC
Date
Msg-id 877kqz5j2t.fsf@npa01zz001.simplot.com
Whole thread Raw
In response to DATE_ADD, DATE_SUB, ETC  (Burra <burra@colorado.edu>)
List pgsql-novice
Uh, I think that you would be surprised what PostgreSQL will let you
do without special functions.

For example:

SELECT '2001-01-01'::timestamp + '1 year'::interval;

        ?column?
------------------------
 2002-01-01 00:00:00-07


You don't even need the explicit casts if the database knows the type
already.  Subtracting timestamps gets you an interval, and intervals
and timestamps can be added (or subtracted) to get a timestamp result.

Jason

Burra <burra@colorado.edu> writes:

> Does postgres have functions that are similar to these mysql functions?
>
> DATE_ADD(date,INTERVAL expr type)
> DATE_SUB(date,INTERVAL expr type)
> ADDDATE(date,INTERVAL expr type)
> SUBDATE(date,INTERVAL expr type)
>
> --------------------[-- burra@colorado.edu --]--------------------------
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

pgsql-novice by date:

Previous
From: Burra
Date:
Subject: DATE_ADD, DATE_SUB, ETC
Next
From: "Josh Berkus"
Date:
Subject: Re: DATE_ADD, DATE_SUB, ETC