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.
I'm not getting any records selected at all.
Any help would be very appreciated.
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.
Try this:
$today = date('Y-m-d H:i:s');
Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com
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.
Re: [Dave] Date Search
By sykomac - January 27, 2010
Dave,
Well, I had to do two things --
1 - I had to change the date to the format you gave me.
2 - I had to change the order of the single and double quotes in the where clause to:
'where' => "startdate <= '$today' AND enddate >= '$today'"
(Double quote at the start and end and single quotes around the variable $today.
Thanks,
Well, I had to do two things --
1 - I had to change the date to the format you gave me.
2 - I had to change the order of the single and double quotes in the where clause to:
'where' => "startdate <= '$today' AND enddate >= '$today'"
(Double quote at the start and end and single quotes around the variable $today.
Thanks,