How to keep items active until timestamp has passed... CURDATE()

Hi all,

I currently list a bunch of events which works good using the below code further down.

The problem is, I have timestamp columns in this events table which generally show the date and time of each event. In the WHERE clause I display the events based on the CURDATE() which works well, though as soon as 12am hits, all events disappear and the next days events show.

This was good until I realised some events run til 3-5am in the morning the next day, which means nobody can see these events if visiting after 12 midnight because the next days events are already showing.

Is there a way to keep the events active until the ending timestamp has lapsed for each event. Or maybe keep all events active for that day until the last events end time has lapsed.

My current setup below:

  SELECT ID
  , DTEND
  , LOCATION
  , DTSTAMP
  , DTSTART
  , DTSTART AS STARTMETA
  , SUMMARY
  FROM events
  WHERE DTSTAMP >= CURDATE()
  ORDER BY DTSTART ASC

DTEND has the ending time

I also tried INTERVAL 1 DAY as shown below but this keeps all the outdated events showing for a full day, which is not what I need as all events are outdated.

WHERE DTSTAMP >= CURDATE() - INTERVAL 1 DAY

Is there a way to achieve this?
Any suggestions?

Thanks,
Barry

tried CURTIME()?

1 Like

Just been testing… it works! :grinning:

Ha been looking at all kinds of stuff here, including MySQL Event Scheduler amongst other things.

This works great now using CURTIME() right down to the exact minute :sunglasses:

Thanks alot r937, brightening up my day, and merry Christmas! :evergreen_tree:

Barry

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.