By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,647 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,647 IT Pros & Developers. It's quick & easy.

mySQL date range query

P: 6
Hi,
I want to select data from a range of dates i.e over a 1 month period

I've tried this:

SELECT * FROM table WHERE DATE_SUB(Date(), INTERVAL 30 DAY)

but the query isnt working as it is retrieving all the data from the database, rather than just that 30 day period (and as a result it crashes)

any suggestions as to why the sql isnt working?

Thanks
Feb 16 '07 #1
Share this Question
Share on Google+
1 Reply


ronverdonk
Expert 2.5K+
P: 4,258
Welcome to The Scripts.

Is this what you are looking for? from_date and end_date depend on what it is your start and end date resp.

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM table WHERE mydate BETWEEN from_date AND to_date 
Ronald :cool:
Feb 16 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.