i have been trying pull records based on specified date. in db have column store unix timestamps. user has option select records based on date. user inputs: 08/08/2016
(for example)
how write sql statement handle this?
$query .= "`".$o."` = '".date("y-m-d",strtotime($v))."' , ";
here see line part of sql statement built, because more 1 column targeted user during search request.
somehow need able turn $o
(which column storing unix timestamps) y-m-d format comparison, shown above , make work in sql statement.
any appreciated.
edit
here worked me:
$query .= "
".$o.">= '".strtotime($v)."' and
".$o."< '".(strtotime($v)+(24*60*60))."' , ";
you can like:
"where date(`$o`) = '".date("y-m-d",strtotime($v))."'"
however won't use indexes, if have large table slower. if want able use indexes can do:
"where `$o` >= ".date("y-m-d",strtotime($v))." , `$o` < ".date("y-m-d",strtotime($v))." + interval 1 day"
Comments
Post a Comment