Skip site navigation (1) Skip section navigation (2)

Re: Select data for current week only

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Select data for current week only
Date: 2009-08-27 18:36:45
Message-ID: h76jnp$eir$1@ger.gmane.org (view raw or flat)
Thread:
Lists: pgsql-general
BlackMage wrote on 27.08.2009 20:09:
> 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.

SELECT *
FROM the_table
WHERE extract(week from the_date_column) = extract(date from current_date);
 
> The field I am using for sorting is a Date type with the format yyyy-mm-dd
> hh:mm:ss .

A date column does not have a format :)

Thomas



In response to

Responses

pgsql-general by date

Next:From: Edwin PlauchuDate: 2009-08-27 18:37:38
Subject: Re: Select data for current week only
Previous:From: Rob SargentDate: 2009-08-27 18:31:23
Subject: Re: [SQL] Data audit trail techniques in postgresql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group