FROM_UNIXTIME(o.created,'%d-%m-%Y') in where clause gives error I am working on Drupal 6. while executing  query when I add
and FROM_UNIXTIME(o.created,'%d-%m-%Y') &lt;  '".arg(3)."'";
to WHERE clause it doesn't return result.
i have tried by using same query in MySQL Query Browser it returns result.
so I am confused how to pass above condition in WHERE clause,
as I am passing 31-10-2012 in arg(3).
You just need to escape the percent sign with another, i.e.,

FROM_UNIXTIME(o.created,'%%d-%%m-%%Y')


Also make sure you use parameter replacement rather than injecting strings directly into the query; you're not protected from SQL injection at the moment.

That would be something like

$sql = "SELECT * FROM {table} WHERE FROM_UNIXTIME(o.created,'%%d-%%m-%%Y') &lt; '%s'";
$result = db_query($sql, arg(3));