auraphp/Aura.SqlQuery

SELECT with date_format

baycoretech opened this issue · 2 comments

how to select column with custom date format?
e.g :
"SELECT * FROM table WHERE DATE_FORMAT(column,'%Y-%m-%d')='$date'"
i tried
$query_select->cols(['cr_visitorID', 'DATE_FORMAT(cr_visitorDate, %Y-%m-%d) as visitordate']) ->from('cr_visitor') ->where('visitordate = :date') ->bindValues([ ':date' => $mindate ]);
not working, is there a function to select column with custom date format? or i have to use raw query?
thank you :)

not working

Can you say what the resulting query string actually looks like? E.g., by calling $select->getStatement().

I'm sorry for long reply and bad english :)
I solved it, i have changed 'DATE_FORMAT(cr_visitorDate, %Y-%m-%d) as visitordate' to 'DATE_FORMAT(cr_visitorDate, \'%Y-%m-%d\') as visitordate'. Thanks :)