Is there way to use entityQuery in order to select nodes with multiple value date field. For example we have a content type event with a field field_event_date which may contain unlimited number of dates. Is there any way to select all event nodes that occur on a certain day? E.g. we have field_event_date equals to

[ 10.09.2018 11.09.2018 13.09.2018 ]

the node with this field should be returned for when "10.09.2018", "11.09.2018", "13.09.2018" is passed, and omitted for any other date (including "12.09.2018).

  • Try this Out:

use Drupal\node\NodeInterface;

    $query = \Drupal::entityQuery('node')
    ->condition('status', NodeInterface::PUBLISHED)
    ->condition('type', 'event')
    ->condition('field_event_date', ['10.09.2018', '11.09.2018', '13.09.2018' ], 'IN')
    ->range(0, 10);

  $result = $query->execute();

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.