Re: Timestamp problems...wrong weeks.

From: DeJuan Jackson <djackson(at)speedfc(dot)com>
To: "Campano, Troy" <Troy(dot)Campano(at)LibertyMutual(dot)com>
Cc: Pgsql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Timestamp problems...wrong weeks.
Date: 2004-04-29 23:10:41
Message-ID: 40918B71.2010500@speedfc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Campano, Troy wrote:

>Is there any way with SQL to get what I'm trying to get?
>Where (in this month, April):
>April 1 - 3 (Week 1)
>April 4 - 10 (Week 2)
>April 11 - 17 (Week 3)
>April 18 - 24 (Week 4)
>April 25 - 30 (Week 5)
>
>Thank you!
>
>~ Troy Campano ~
>
>
>
>-----Original Message-----
>From: pgsql-general-owner(at)postgresql(dot)org
>[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Andrew Sullivan
>Sent: Thursday, April 29, 2004 3:42 PM
>To: Pgsql-General
>Subject: Re: [GENERAL] Timestamp problems...wrong weeks.
>
>On Thu, Apr 29, 2004 at 02:42:49PM -0400, Campano, Troy wrote:
>
>
>>This is causing my reports to print out incorrect data.
>>Do you know why this would happen? Am I doing something wrong?
>>
>>
>
>I think you may be misunderstanding what "W" means:
>
>week of month (1-5) (The first week starts on the first day of the
>month.)
>
>In April 2004, 1 April is Thurs, so
>
>1-7 -> W1
>8-14 -> W2
>15-21 -> W3
>22-28 -> W4
>29-30 -> W5 == W1 of May
>
>This is also why 8 May is in week 2 of May, but 7 May is on week 1.
>
>A
>
>
>
take a look

select date_part('week', CURRENT_DATE) -
date_part('week', date_trunc('month', CURRENT_DATE)) + 1;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-04-29 23:23:24 Re: postgresql idle
Previous Message Tom Lane 2004-04-29 22:58:35 Re: Plpgsql problem passing ROWTYPE to function