how to implement substring() in db_select statement I am porting a drupal 6 module to drupal 7. I came across this SQL query:

SELECT count(*) AS total FROM {counter} WHERE SUBSTRING(counter_date,1,10)= '%s'


How to implement the same query in db_select. db_select() will have substring() in its condition clause.
A couple quick greps suggest something like this...

$query-&gt;where('SUBSTRING(counter_date,1,10) = :arg', array(':arg' =&gt; $arg));


...should do it.