Re: [GENERAL] Select data for current week only

2009-08-30 Thread Jasen Betts
On 2009-08-27, BlackMage 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 t

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Thomas Kellerer
Sam Mason wrote on 27.08.2009 21:06: The OP leaves it somewhat open, but wouldn't date_trunc be better here? Otherwise you'll end up getting values for other years as well as the current one. Good point, I didn't think of that :) As an alternative, one could explicitely add the year into the

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Sam Mason
On Thu, Aug 27, 2009 at 11:09:36AM -0700, BlackMage wrote: > The field I am using for sorting is a Date type with the format -mm-dd > hh:mm:ss . Values that look like that are normally stored in timestamp columns, not date column. You wouldn't get the time part if it was just a date. -- S

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Sam Mason
On Thu, Aug 27, 2009 at 08:36:45PM +0200, Thomas Kellerer wrote: > BlackMage wrote on 27.08.2009 20:09: > >I only want to select events happening for the current week(Mon-Sun). > > SELECT * > FROM the_table > WHERE extract(week from the_date_column) = extract(date from current_date); The OP leave

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Gerhard Heift
On Thu, Aug 27, 2009 at 11:09:36AM -0700, BlackMage 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

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Edwin Plauchu
you need to group dates per number week 2009/8/27 Edwin Plauchu > Postgresql has these functions > http://www.postgresql.org/docs/8.1/static/functions-formatting.html for > formatting data time > > > 2009/8/27 BlackMage > > >> Hey all, >> >> I've been trying to figure this problem out with just

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Edwin Plauchu
Postgresql has these functions http://www.postgresql.org/docs/8.1/static/functions-formatting.html for formatting data time 2009/8/27 BlackMage > > 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

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Thomas Kellerer
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 sq

[GENERAL] Select data for current week only

2009-08-27 Thread BlackMage
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 sort