Strange results with date/interval arithmetic
От | Bruce Momjian |
---|---|
Тема | Strange results with date/interval arithmetic |
Дата | |
Msg-id | 200201081910.g08JAoJ13410@candle.pha.pa.us обсуждение исходный текст |
Ответы |
Re: Strange results with date/interval arithmetic
|
Список | pgsql-hackers |
I am seeing strange results from date/interval computations involving months. I get the correct answers because I have a negative setting relative to GMT. Here are my results with TZ=EST5EDT:test=> select '2001/3/1'::date - '1 month'::interval; ?column? ------------------------2001-02-01 00:00:00-05(1 row) With GMT it is OK too: test=> select '2001/3/1'::date - '1 month'::interval; ?column? ------------------------ 2001-02-01 00:00:00+00(1row) However, with GMT+1 I see a big failure: test=> select '2001/3/1'::date - '1 month'::interval; ?column? ------------------------ 2001-01-29 00:00:00+01(1row) Why does it say 2001-01-29? This is interesting:test=> select '2001/7/1'::date - '1 month'::interval; ?column? ------------------------2001-05-31 00:00:00+02(1 row)test=> select '2001/8/1'::date - '1 month'::interval; ?column? ------------------------ 2001-07-01 00:00:00+02(1 row) Because August and July have the same number of months, it worked. I am going to research this but someone may know the solution already. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania19026
В списке pgsql-hackers по дате отправления: