Mysql, php query WHERE statement, recordset expire in +1 day of post date?
I ba开发者_高级运维sically have a simple calendar I set up. As of now, it shows "future" events. And then the event expires that day... I would love to find a WHERE statement that I can use to have that "event" stay up for 1 day past the "post_date"
(so if I post it as Nov. 15th,) The event would show: Name of event - Nov. 15th
And It would stay active until +1 day from post_date? (Nov. 16th would be the expire date)
Here is what I have so far:
WHERE DATE(FROM_UNIXTIME(`date`)) >= DATE(NOW())
Thanks in advance...
WHERE post_date > DATE(NOW())-INTERVAL 1 DAY
and if you really want to keep your post_date
s in UNIX timestamps:
WHERE FROM_UNIXTIME(post_date) > DATE(NOW())-INTERVAL 1 DAY
Change your where statement to:
WHERE DATE(FROM_UNIXTIME(`date`)) + INTERVAL 1 DAY >= CURDATE();
Also a good idea to to use real SQL dates instead of UNIX timestamps. There are functions to do calculations on them.
精彩评论