$stmt = $dbh->prepare("select * table1 t1 inner join table2 t2 on t1.id = t2.id t1.username = :user , date_format(t2.date, 'y-m-d') == :time"); $stmt->bindvalue(':time', date_format($time, 'y-m-d'), pdo::param_str); $stmt->bindvalue(':user', $user, pdo::param_str);
i have code check if date equal. equal means same day january 1, 1990 == january 1, 1990
but getting date_format() expects parameter 1 datetimeinterface,
what appropriate way compare date if same day in mysql clause
try mysql str_to_date
$stmt = $dbh->prepare("select * table1 t1 inner join table2 t2 on t1.id = t2.id t1.username = :user , str_to_date(t2.date,'%m %d, %y') == :time"); $stmt->bindvalue(':time', str_to_date($time,'%m %d, %y'), pdo::param_str); $stmt->bindvalue(':user', $user, pdo::param_str);
Comments
Post a Comment