Обсуждение: odd date behavior

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

odd date behavior

От
Gregory Seidman
Дата:
The first day of the week, day 0, is Sunday. Or is it Monday? If I use
extract (dow from date) it will give me 0 for Sunday, but if I use extract
(week from date) the weeks start on Mondays. Observe:

template1=> SELECT extract (week from '2002-06-01'::date), extract (week from '2002-06-02'::date), extract (week from
'2002-06-03'::date);
 date_part | date_part | date_part
-----------+-----------+-----------
        22 |        22 |        23
(1 row)

template1=> SELECT extract (dow from '2002-06-01'::date), extract (dow from '2002-06-02'::date), extract (dow from
'2002-06-03'::date);
 date_part | date_part | date_part
-----------+-----------+-----------
         6 |         0 |         1
(1 row)

template1=> select version();
                           version
-------------------------------------------------------------
 PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.96

Is this the expected behavior? Where is it documented? Can it be changed?

--Greg