mySQL compare dates
1 posts by 1 authors in: Forums > CMS Builder
Last Post: December 5, 2010 (RSS)
By eduran582 - December 5, 2010 - edited: December 5, 2010
DISREGARD THIS QUESTION *** Problem wasn't with the code; it was with another related issue.
Sorry for the waste of electrons [blush]
Hello all,
I'm having a problem extracting a date range from a table with a 'date' field (mySQL format: Y-m-d 00:00:00). I load the table and use the where statement to list the dates equal to or greater than today's date which is defined as:
When I run the following, I only get about 1/3 of the dates in the table that are greater or equal to $tuday:
I'm really at a loss. I've even tried counting the records using a mySQL statement:
It too yields the incorrect count. I even tried using the Epoch date comparison:
But the same (incorrect) count came up. I'm not talkin' about just a few records; for this particular instance, it will list 138 records instead of the 914 that are matching (went to the table and counted).
I've been at this so long now, I'm sure I'll make more mistakes than I may have already made and decided to ask those that know a heck of a lot more about this than me. [crazy]
ANY help will be appreciated. [:/]
TIA.
Eric
Sorry for the waste of electrons [blush]
Hello all,
I'm having a problem extracting a date range from a table with a 'date' field (mySQL format: Y-m-d 00:00:00). I load the table and use the where statement to list the dates equal to or greater than today's date which is defined as:
$tuday = date('Y-m-d 00:00:00',time());
When I run the following, I only get about 1/3 of the dates in the table that are greater or equal to $tuday:
// filter by visiting date
list($visiting_currentRecords, $visiting_currentMetaData) = getRecords(array(
'tableName' => 'visiting_current',
'orderBy' => 'visit_date',
'where' => "visit_date >= '$tuday'",
'loadUploads' => '0',
'limit' => '0',
));
$visiting_currentRecord = @$visiting_currentRecords[0]; // get first record
I'm really at a loss. I've even tried counting the records using a mySQL statement:
$query = "SELECT count(*) FROM cms_visiting_current WHERE visit_date >= '$tuday'";
$gCount= mysql_result (mysql_query ($query), 0);
It too yields the incorrect count. I even tried using the Epoch date comparison:
$query = "SELECT count(*) FROM cms_visiting_current WHERE UNIX_TIMESTAMP(visit_date) >= '$tdayepoch'";
$gCount= mysql_result (mysql_query ($query), 0);
But the same (incorrect) count came up. I'm not talkin' about just a few records; for this particular instance, it will list 138 records instead of the 914 that are matching (went to the table and counted).
I've been at this so long now, I'm sure I'll make more mistakes than I may have already made and decided to ask those that know a heck of a lot more about this than me. [crazy]
ANY help will be appreciated. [:/]
TIA.
Eric