Date Search

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 27, 2010   (RSS)

By sykomac - January 26, 2010

I'm trying to search for records between a certain date and am having problems with my where clause.

startdate and enddate are fields in my database.

$today = date('Y-m-d');
require_once "/admin/lib/viewer_functions.php";
list($home_tilesRecords, $home_tilesMetaData) = getRecords(array(
'tableName' => 'home_tiles',
'where' => 'startdate <= "$today" AND enddate >= "$today"',
));


I'm not getting any records selected at all.

Any help would be very appreciated.

Re: [sykomac] Date Search

By Dave - January 27, 2010

Hi sykomac,

Try this:
$today = date('Y-m-d H:i:s');

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

Re: [sykomac] Date Search

By sykomac - January 27, 2010

I haven't tried that yet, but my date fields are stored as just a date and no time.