odd date behavior

From: Gregory Seidman <gss+pg(at)cs(dot)brown(dot)edu>
To: PostgreSQL General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: odd date behavior
Date: 2002-06-13 18:46:45
Message-ID: 20020613184645.GA15815@cs.brown.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Browse pgsql-general by date

  From Date Subject
Next Message tony 2002-06-13 19:05:51 read this and puke
Previous Message Neil Conway 2002-06-13 18:37:07 Re: Contrib reindex script: