help with date_part & day of week

From: <me(at)alternize(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: help with date_part & day of week
Date: 2005-12-29 23:44:25
Message-ID: 0a2c01c60cd1$ce1049f0$6402a8c0@iwing
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

hi list

from the user manual:
---------------------------------------
dow
The day of the week (0 - 6; Sunday is 0) (for timestamp values only)
SELECT EXTRACT(DOW FROM TIMESTAMP '2001-02-16 20:38:40');
Result: 5
Note that extract's day of the week numbering is different from that of
the to_char function.
---------------------------------------

now it happens that in europe it is common to have monday as the first day
of week. as far as i know, mssql uses the local os setting for determining
which value should be returned for a sunday. one select statement we're
trying to migrate from mssql to pgsql depends on the ordering of records
according to their day of week value - where monday is the first day. how
can this be fixed in pgsql?

the (simplified) query in question:
SELECT date_part('year', date_added) AS year, date_part('week', date_added)
AS week, date_part('dow', date_added) AS day, id FROM entries ORDER BY year,
week, day

btw: date_part('week', ...) already recognizes monday being the first day of
week accordingly to ISO-8601.

thanks,
thomas

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruce Momjian 2005-12-30 01:00:00 Re: help with date_part & day of week
Previous Message Oliver Elphick 2005-12-29 23:37:11 Re: ?linux distro?