I've got a typical date field that collects start and end date values. I want to exclude results from my calendar view where the date value has a duration that is longer than 24 hours. It would be even better to exclude results where the duration spans midnight, but one thing at a time. I don't see how the date filter in views will let me compare the two date values something like this: if (end date) > ((start date) + 24hrs) then exclude results.

This is a marginally popular topic, I think:
http://drupal.org/node/1741312
http://drupal.org/node/769506

Any thoughts? Thanks in advance.

Comments

monish_deb’s picture

Yes you can achieve this functionality using "Global:PHP" as View filter and paste the following PHP code(without delimiter) in "Filter Code"

$offset =  strtotime('+24 hours', $data->field_field_date[0]['raw']['value']);
$end_date = strtotime($data->field_field_date[0]['raw']['value2']);
if ($end_date > $offset) {
return FALSE;
}
else {
return TRUE;
}

I have make use of $data variable, likewise there are other variables available which you can make use of.
Works for me.

monish_deb’s picture

Issue summary: View changes

More information...