How to filter nodes using date field I have a content type of "Class" that has a date field attached to it field_class_date.

When a node of the type "Class" is viewed, I would like to display links to other classes that are on the same day of that particular class.

I tried doing this with views, but couldn't quite figure it out.
To solve this, (1) I placed code in node--class.tpl.php which retrieved the current class date

$date = entity_metadata_wrapper('node', $node)-&gt;field_class_date-&gt;value-&gt;value();


Then, (2) I modified that value to get the start of the day and the end of the day ($start and $end) in the following format: Y-m-d H:i:s

(3) Perform a query using EFQ to grab a list of the nodes that share the same date:

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'class')
  -&gt;fieldCondition('field_class_date', 'value', array($start, $end), 'BETWEEN')
  -&gt;fieldOrderBy('field_class_date', 'value', 'ASC');
$result = $query-&gt;execute();


(4) Loop through each result and create the content I want to display later in node--class.tpl.php

foreach($result['node'] as $i) {
  $node = node_load($i-&gt;nid);
  $date = entity_metadata_wrapper('node', $node)-&gt;field_class_date-&gt;value-&gt;value();
  $name = entity_metadata_wrapper('node', $instructor)-&gt;field_class_instructor-&gt;value();
  // Build a string of output that I want to display later in the $content array
  $classes_today = etc...
}


(5) Finally, I added the $classes_today string to the $content array:

$content['more_classes']['#prefix'] = '&lt;h2 class="classes-on-this-day"&gt;Classes on this Day:&lt;/h2&gt;&lt;div class="more-classes"&gt;';
$content['more_classes']['#markup'] = $more_classes;
$content['more_classes']['#weight'] = '4';
$content['more_classes']['#suffix'] = '&lt;/div&gt;';