Re: Select data for current week only

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Select data for current week only
Date: 2009-08-30 12:51:55
Message-ID: h7dslb$84m$3@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2009-08-27, BlackMage <dsd7872(at)uncw(dot)edu> wrote:
>
> Hey all,
>
> I've been trying to figure this problem out with just using sql but I'm not
> sure how too. I have a table that holds events for each week but I only want
> to select events happening for the current week(Mon-Sun). So can anyone help
> me out with this just using sql? I've accomplished it sorta using php but
> only within the current 7 day range(example Thursday-Thursday) but not by
> the week.
>
> The field I am using for sorting is a Date type with the format yyyy-mm-dd
> hh:mm:ss .

sounds like a timestamp. case it to date

yourfield :: date
between
'today' :: date - extract (DOW from 'today' :: date )
and
'today' :: date - extract (DOW from 'today' :: date ) + 6

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Cuppett 2009-08-30 13:11:53 Re: Trouble using TG_TABLE_NAME in BEFORE INSERT OR UPDATE trigger
Previous Message Jasen Betts 2009-08-30 12:48:02 Re: Removing older versions