User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 397,798 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,372 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 14191 | Replies: 1
Reply
Join Date: Aug 2006
Posts: 9
Reputation: bobby08 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
bobby08 bobby08 is offline Offline
Newbie Poster

MySQL SELECT rows In a Date Range

  #1  
Aug 21st, 2006
Hello,

I was wondering if there anyway to Select rows where the date column falls into a certain range?

For example, heres a table

The date field is generated automatically by MySQL with the DATE function

Heres the table:

[user] . [wins].  [date]
bobby.......4..... 2006-08-21
boby1.......3..... 2006-08-22
boby2.......6..... 2006-08-24
boby3.......1..... 2006-08-29

Now I need to filter this data out so that I can have the end user browse weekly results. I'm stuck on a SELECT syntax statement that can pull any rows from any dates ranging from 8-21 to 8-27 (Monday to Sunday this month).

If this was the case, the last row , boby3 who has 1 wins on 08-29 will not be displayed for this current week's result.

I already have this which ranks users OVERALL season wins:
SELECT user, sum(wins) from results GROUP BY user ORDER by wins

Does anyone know any referrences regarding this issue?

Thanks for reading this,
Bobby
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2005
Location: Manchester, UK
Posts: 481
Reputation: pty is on a distinguished road 
Rep Power: 3
Solved Threads: 31
pty's Avatar
pty pty is offline Offline
Posting Pro in Training

Re: MySQL SELECT rows In a Date Range

  #2  
Aug 22nd, 2006
Originally Posted by bobby08 View Post
Hello,

I was wondering if there anyway to Select rows where the date column falls into a certain range?

For example, heres a table

The date field is generated automatically by MySQL with the DATE function

Heres the table:

[user] . [wins].  [date]
bobby.......4..... 2006-08-21
boby1.......3..... 2006-08-22
boby2.......6..... 2006-08-24
boby3.......1..... 2006-08-29

Now I need to filter this data out so that I can have the end user browse weekly results. I'm stuck on a SELECT syntax statement that can pull any rows from any dates ranging from 8-21 to 8-27 (Monday to Sunday this month).

If this was the case, the last row , boby3 who has 1 wins on 08-29 will not be displayed for this current week's result.

I already have this which ranks users OVERALL season wins:
SELECT user, sum(wins) from results GROUP BY user ORDER by wins

Does anyone know any referrences regarding this issue?

Thanks for reading this,
Bobby


select *
from table
where date >= [start date] and date <= [end date]
or (i'm not 100% sure if this works in mysql but it does in postgres!)
select * 
from table 
where date between [start date] and [end date]
Last edited by pty : Aug 22nd, 2006 at 5:11 am. Reason: added code tags
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 5:51 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC