pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <andreas.kretschmer@schollglas.com>
To: pgsql-sql@postgresql.org
Subject: Re: Extract week from date, start with sunday
Date: Mon, 7 Nov 2005 15:27:48 +0100
Message-ID: <20051107142748.GW9910@webserv.wug-glas.de> (raw)
In-Reply-To: <20051107140036.11DC6D6873@svr1.postgresql.org>
References: <20051107140036.11DC6D6873@svr1.postgresql.org>

am  07.11.2005, um 14:47:35 +0100 mailte Robert Blixt folgendes:
> 
>  Hi,
> 
> 
> I am currently extracting my weeks from a date like this..
> 
> SELECT INTO extractweek EXTRACT( week FROM ldate );
> 
> This works fine, except that this assumes (according
> to ISO standard) that weeks starts with Monday.
> 
> I need the weeks to start with Sunday instead, otherwise
> I will not get the correct week.
> 
> Is there a workaround for this?

Add 1 day to ldate.

test=# select to_char('2005-11-05'::date+'1 day'::interval, 'IW');
 to_char
---------
 44
(1 row)

test=# select to_char('2005-11-06'::date+'1 day'::interval, 'IW');
 to_char
---------
 45
(1 row)


HTH, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    === 



view thread (4+ messages)  latest in thread

Message-ID: <20051107142748.GW9910@webserv.wug-glas.de>
Permalink:  ../20051107142748.GW9910@webserv.wug-glas.de/
Also on:    postgresql.org/message-id/20051107142748.GW9910@webserv.wug-glas.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andreas.kretschmer@schollglas.com
  Subject: Re: Extract week from date, start with sunday
  In-Reply-To: <20051107142748.GW9910@webserv.wug-glas.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox