How can I do a MySQL date function in Drupal? I have this now:
$select = db_select('someTable', 'st');
$select->addExpression('DATE_FORMAT(FROM_UNIXTIME(created), "%Y-%m")', 'createdMonth');
$date = $select->execute()->fetchAll();
When I run this I get an exception that says:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column '%Y-%m' in 'field list'"
But if I print the $select object I see it should run
SELECT DATE_FORMAT(FROM_UNIXTIME(created), "%Y-%m") AS createdMonth FROM {someTable} st
And when I copy this to Sequel Pro it just runs.
What am I missing?