I am strugginling to find out how to execute the below query using drupal's db api
$startdate = '1491001200';
$enddate = '1498690799';
"SELECT * FROM field_data_field_symposium_event_time
WHERE UNIX_TIMESTAMP(field_symposium_event_time_value) BETWEEN
$startdate AND $enddate;"
I have tried adding 'addExpression' but does not work. I did it like this
$query = db_select('node','n');
$query->join('field_data_field_symposium_event_time', 'et', 'et.entity_id = n.nid');
$query->condition('et.field_data_field_symposium_event_time_value',array($day_start, $day_end), 'BETWEEN'));
$query->addExpression('UNIX_TIMESTAMP(et.field_symposium_event_time_value)');
$query->fields('et',array('field_symposium_event_time_value'));
$result = $query->execute()->fetchAll();
The $result
is empty. Is there a way to achieve this as I dont want to write the full query .