auraphp / Aura.SqlQuery

Independent query builders for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.
MIT License
452 stars 86 forks source link

SELECT with date_format #137

Closed baycoretech closed 7 years ago

baycoretech commented 7 years ago

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 :)

pmjones commented 7 years ago

not working

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

baycoretech commented 7 years ago

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 :)