Question

I basically 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...

Was it helpful?

Solution

WHERE post_date > DATE(NOW())-INTERVAL 1 DAY

and if you really want to keep your post_dates in UNIX timestamps:

WHERE FROM_UNIXTIME(post_date) > DATE(NOW())-INTERVAL 1 DAY

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top