Re: Grouping by week - Mailing list pgsql-sql

From Tom Lane
Subject Re: Grouping by week
Date
Msg-id 24169.1091832777@sss.pgh.pa.us
Whole thread Raw
In response to Re: Grouping by week  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: surrogate key or not?
Next
From: Kenneth Gonsalves
Date:
Subject: Re: surrogate key or not?