Jump to content

Recommended Posts


[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?
Link to comment
https://forums.phpfreaks.com/topic/7571-not-getting-future-dates/
Share on other sites

[!--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--]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.