From: Tom Lane <tgl@sss.pgh.pa.us>
To: olly@lfix.co.uk
Cc: Caleb Simonyi-Gindele <csg@bordervet.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: Grouping by week
Date: Fri, 06 Aug 2004 18:52:57 -0400
Message-ID: <24169.1091832777@sss.pgh.pa.us> (raw)
In-Reply-To: <1091830111.13140.1.camel@linda>
References: <000001c47bfc$69d79e50$c201a8c0@borderveygqj37>
<1091830111.13140.1.camel@linda>
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
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: tgl@sss.pgh.pa.us, olly@lfix.co.uk, csg@bordervet.ca
Subject: Re: Grouping by week
In-Reply-To: <24169.1091832777@sss.pgh.pa.us>
* 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