Birdofprey Posted April 17, 2006 Share Posted April 17, 2006 [code] SELECT * FROM table WHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= 'Date' Order By 'Date' DESC Limit 14[/code]Hi,I'm using this to get the most recent 30 entires, but it also gives me future entries which hasn't arrive yet. Is there a way for me to query it so that only the current date and the last 30 days are called and not the future entires? Quote Link to comment Share on other sites More sharing options...
shoz Posted April 17, 2006 Share Posted April 17, 2006 [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][color=green]WHERE[/color] DATE_SUB(CURDATE(), INTERVAL 30 DAY) [color=orange]<[/color][color=orange]=[/color] `Date` [color=blue]AND[/color] `Date` [color=orange]<[/color][color=orange]=[/color] CURDATE() [!--sql2--][/div][!--sql3--][!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][color=green]WHERE[/color] `Date` [color=orange]>[/color][color=orange]=[/color] DATE_SUB(CURDATE(), INTERVAL 30 DAY) [color=blue]AND[/color] `Date` [color=orange]<[/color][color=orange]=[/color] CURDATE() [!--sql2--][/div][!--sql3--] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.