Re: DATE_ADD, DATE_SUB, ETC

Поиск
Список
Период
Сортировка
От Jason Earl
Тема Re: DATE_ADD, DATE_SUB, ETC
Дата
Msg-id 877kqz5j2t.fsf@npa01zz001.simplot.com
обсуждение исходный текст
Ответ на DATE_ADD, DATE_SUB, ETC  (Burra <burra@colorado.edu>)
Список 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 по дате отправления:

Предыдущее
От: Burra
Дата:
Сообщение: DATE_ADD, DATE_SUB, ETC
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: DATE_ADD, DATE_SUB, ETC