I am sure this is the default or error in db_query / db_select.
Suppose you saved your timestamp in a database with the following format 2014-12-15 09:38:04 or just 2014-12-15
Now suppose you want to search for all rows related to one day. If you selected a raw MySQL query using BETWEEN, it will work just fine. Example:
select * from table where timestamp between "2014-12-15" and "214-12-15";
However, if you create a query using db_query or db_select, the expression below will not work: Example:
$query->condition('timestamp', array("2014-12-15", "2014-12-15"), 'BETWEEN');
For some reason, Drupal seems to be comparing from 2014-12-15 0: 0: 0 to 2014-12-15 0: 0: 0.
If you create a condition in the following format, it will work
$query->condition( 'timestamp', array("2014-12-15", "2014-12-15" . ' 23:59:59'), 'BETWEEN' );
Using real filters, the operator will look like this:
$query->condition( 'timestamp', array($stardate, $endate . ' 23:59:59'), 'BETWEEN' );
I hope that I am wrong about this Drupal problem. Because it is really lame.
Regards, Sharif.