FROM_UNIXTIME(o.created,'%d-%m-%Y') in where clause gives error
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));