Re: Grouping by week

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Grouping by week
Дата
Msg-id 24169.1091832777@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Grouping by week  (Oliver Elphick <olly@lfix.co.uk>)
Список pgsql-sql
Oliver Elphick <olly@lfix.co.uk> writes:
> How about:
>    SELECT EXTRACT(WEEK FROM trans_date + '1 day'::INTERVAL)

Note that if trans_date is actually a date, you are much better off just
adding an integer to it:    SELECT EXTRACT(WEEK FROM trans_date + 1)
If you add an interval then the date will be promoted to a timestamp,
and all of a sudden you have possible issues with funny behavior at
DST boundaries.

I think since 7.3 the DST issue is only serious if trans_date is
actually stored as timestamp with time zone, but it has been able to
bite you in the past.
        regards, tom lane


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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: surrogate key or not?
Следующее
От: Kenneth Gonsalves
Дата:
Сообщение: Re: surrogate key or not?