I have an entity and one of it's properties is a timestamp, set when it was created.
I want to use EntityFieldQuery to load entities that were created today.
Normally if I was writing a query to do this I would use:
DATE_FORMAT(FROM_UNIXTIME(created_timestamp), "%Y-%m-%d") = "2014-03-17"
However I'm not aware of any method to use any MySQL functions in EntityFieldQuery, so instead I've used:
$day_start = strtotime(date('Y-m-d 00:00:00', $created_ts)); $day_end = strtotime(date('Y-m-d 23:59:59', $created_ts)); $query ->propertyCondition('created', $day_start, '>') ->propertyCondition('created', $day_end, '<');
Whilst this works it doesn't seem as efficient and certainly less succinct. Is there a function that I can use with EntityFieldQuery similar to dynamic queries where function that would allow me to do something like:
$query ->propertyWhere('DATE_FORMAT(FROM_UNIXTIME(created), "%Y-%m-%d")', "2014-03-17");