displaying tonights performing artist

18 posts by 7 authors in: Forums > CMS Builder
Last Post: February 24, 2012   (RSS)

By rez - March 12, 2010

Just what I needed, thanks. :)

By RGC - February 23, 2012

I am currently using this code to display only upcoming events

<?php
// load records
list($eventRecords, $eventMetaData) = getRecords(array(
'tableName' => 'event',
'where' => 'date > NOW()',

));
?>

The code works fine displaying only upcoming events, except the day of the event the event does not display! How can i modify this code to display upcoming events including events the same day ?
Rod

Re: [Jason] displaying tonights performing artist

By RGC - February 23, 2012

I tried that, but today's event still does not display .... it will only display if i change the event date to tomorrow
Rod

Re: [rgc] displaying tonights performing artist

By Dave - February 23, 2012

Hi rgc,

Date math can be a bit tricky, I wrote a post about it here:
http://www.interactivetools.com/forum/gforum.cgi?post=78159#78159

What you want is to get the time of the "end of the day". Try replacing NOW() with this:
TIMESTAMP(CURDATE(), "23:59:59")

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

By RGC - February 23, 2012

Thanks for the code Dave, but that did not work, the event dated today did not display .... I am using the following code which appears to work fine, i will just have to check to see that the event gets automatically removed tomorrow (which will be the day after the event). Here is the code i am using:
<?php
list($eventRecords, $eventMetaData) = getRecords(array(
'tableName' => 'event',
'where' => " date >= TIMESTAMP( DATE(NOW() - INTERVAL 1 HOUR) ) ",
));
?>
Rod

Re: [rgc] displaying tonights performing artist

By Dave - February 23, 2012

Ahh, I missed the "upcoming" events part and was thinking of "previous" dates. Yea, it's the time part of the date that is causing the challenge.

Your code will show all events on the current day and forward, except between midnight and 1am, in which case it will show the previous day as well.

That might actually be a useful trick if you expected people would check events after midnight. Or failing that, another way to write it would be like this:

date >= CURDATE()

Good luck!
Dave Edis - Senior Developer
interactivetools.com

By RGC - February 24, 2012

Perfect! This is the code i was looking for:
<?php
list($eventRecords, $eventMetaData) = getRecords(array(
'tableName' => 'event',
'where' => " date >= CURDATE() ",
));
?>

Both events of the current day and future events display. Thanks Dave
Rod