I have a basic query fetching results for all results earlier than today:
...where post_date < '"开发者_运维知识库.current_time('mysql')."'....
How do I only fetch results for the past 6 months, i.e.:
...where post_date > '".current_time('mysql')."' - 6 MONTHS && post_date < '".current_time('mysql')."'...
Use DATE_SUB (and GETDATE()
)
...where post_date > DATE_SUB(GETDATE(), INTERVAL 6 MONTH) ...
eg:
... WHERE post_date > NOW() - INTERVAL 6 MONTH
精彩评论