Обсуждение: Trouble with dates

Поиск
Список
Период
Сортировка

Trouble with dates

От
Bassel Hatoum
Дата:
I'm trying to add months to a date without having to calculate how many
days in the month, etc.
Oracle has an add_month function that would do the trick.  It there
anything similar in PGSQL?  Or maybe a way to emulate it?

Thanks in advance.

Bassel Hatoum


Re: [SQL] Trouble with dates

От
Marin D
Дата:
CREATE TABLE test (d DATE);

INSERT INTO test VALUES (CURRENT_DATE);


test=> SELECT DATE( DATETIME(d) + '1 month'::TIMESPAN) FROM test;

      date
----------
30-06-1998
(1 row)

test=>


Hope this helps...

    Marin

          -= Why do we need gates in a world without fences? =-


On Sat, 30 May 1998, Bassel Hatoum wrote:

> I'm trying to add months to a date without having to calculate how many
> days in the month, etc.
> Oracle has an add_month function that would do the trick.  It there
> anything similar in PGSQL?  Or maybe a way to emulate it?
>
>