SQL Order By question

ORDER BY RecordDate DESC

In the above, I can get the desired date in descending order result. How would I limit the output to not show dates that are newer than 3 days or older than 30?

http://towtalk.net ... Hosted by Zarconia.net!
Quote · 27 Feb 2014

SELECT * FROM `whatever_table` WHERE `RecordDate`  = CURDATE() - INTERVAL 30 DAY ORDER BY `RecordDate` DESC

 

you could try something like this to get results for last 30 days. I haven't tested but hope it points you in the right direction.

caredesign.net
Quote · 27 Feb 2014

Here's what I finally came up with. Seems to work.

FROM violations
WHERE (DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= RecordDate)
AND (DATE_ADD(CURDATE(),INTERVAL -3 DAY) > RecordDate)
ORDER BY RecordDate DESC

It returns all violations older than 3 days but not more than 30 days from today's date.

http://towtalk.net ... Hosted by Zarconia.net!
Quote · 27 Feb 2014
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.