467,895 Members | 1,384 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,895 developers. It's quick & easy.

mySQL date range query

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
  • viewed: 4487
Share:
1 Reply
ronverdonk
Expert 4TB
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.

Similar topics

3 posts views Thread by Noyb | last post: by
2 posts views Thread by sixdeuce62 | last post: by
1 post views Thread by flumpuk | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.