Re: Inconsistant DOW...

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Inconsistant DOW...
Дата
Msg-id 40E04EFB.2050407@archonet.com
обсуждение исходный текст
Ответ на Inconsistant DOW...  ("W.B.Hill" <bill@hillzaa1.miniserver.com>)
Ответы Re: Inconsistant DOW...
Список pgsql-general
W.B.Hill wrote:
> Hiya!
>
> What's happening, where've I goofed?
>
> CREATE TABLE test (d date);
[snip]
>
> This is good - every Easter's on a Sunday so far...
>
> SELECT d+'45 days ago'::interval FROM test;
>         ?column?
> ------------------------
>  2004-02-25 23:00:00+00
>  2005-02-10 00:00:00+00
>  2006-03-01 23:00:00+00
>  2007-02-21 23:00:00+00
>  2008-02-07 00:00:00+00
>  2009-02-25 23:00:00+00
>  2010-02-17 23:00:00+00
> (7 rows)
>
> Why the different times??? Why the times???

At a guess, the date is being converted into a timestamp with timezone
so you can add the interval to it. At another guess, the 1hr difference
is due to the effects of daylight-savings-time (or whatever it's called
in your locale).

I've got a feeling '45 days'==45*'24 hours' which, going over a DST
boundary isn't true for one day. Simplest solution would probably be to
add a few hours to the date before doing your calculations and then
casting back to a date.

--
   Richard Huxton
   Archonet Ltd

В списке pgsql-general по дате отправления:

Предыдущее
От: Adam Ruth
Дата:
Сообщение: Re: Group by - Case insensitivity
Следующее
От: Patrick Welche
Дата:
Сообщение: Re: Inconsistant DOW...