Hey Drupalistas

I am not getting any results on an exposed date field in views.

To reproduce:
- simplytest.me, add date field to a content type.
- views: exposed filter on date field, choose operator "is equal to".

Strange thing one:
I could not find a node on the inputted date, but I did find one when I did date +1 day.
Being from Belgium, date +2h is added. For some strange reason the system is adding dates with 22h by default, if you count 2h to that you are at the next day.

Strange thing two:
If I use datetime with time, I can only get a result when I enter the full date & time like this "05/27/2016T9:00". Nobody is going to do this, especially not with a T between date and time.

The query is this:

SELECT node_field_data.created AS node_field_data_created, node_field_data.nid AS nid
FROM 
{node_field_data} node_field_data
LEFT JOIN {node__field_date} node__field_date ON node_field_data.nid = node__field_date.entity_id AND (node__field_date.deleted = '0' AND node__field_date.langcode = node_field_data.langcode)
WHERE (( (node_field_data.status = '1') AND (node_field_data.type IN  ('article')) AND (DATE_FORMAT(node__field_date.field_date_value, '%Y-%m-%d\T%H:%i:%s') = DATE_FORMAT('2016-05-27T07:00:00', '%Y-%m-%d\T%H:%i:%s')) ))
ORDER BY node_field_data_created DESC
LIMIT 11 OFFSET 0

I just want to enter "05/27/2016" (or get the string via a jQuery date popup) and get my nodes which have that date ...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yvesvanlaer created an issue. See original summary.

mpdonadio’s picture

Few different things report here.

Can you try the patch in #2627512: Datetime Views plugins don't support timezones to see if it fixes your problem w/ filtering?

Also, can you try the patch in #2648950: [PP-2] Use form element of type date instead textfield when selecting a date in an exposed filter which should enable the date/time picker? (Also, potentially #1838234: Add jQuery Timepicker for the Time element of the datetime field for the timepicker polyfill for Firefox).

mpdonadio’s picture

I you think you have a different issue, change the status back to Active and leave a comment. After re-reading this, it sounds like a duplicates of the issues I linked.

yvesvanlaer’s picture

Hey mpdonadio, thanks for looking into this.

I should have created more issue topics.

As for now, users cannot filter nodes based on a date. I can only get it to work when they enter in *date*+1.
I figured this had something to do with the timezone.
I wanted to apply patch #48 in #2627512: Datetime Views arguments don't support timezones but it is doing something wrong. (see screenshot). It created code before the <?php. I will comment this also on the other topic if necessary.

Either way it is not functional yet:
if I select date, it is date +1 that they have to enter to get a result.
if I select date + time people have to enter "05/27/2016T9:00" to get a result, although people only want to know what is going on on a certain date (without knowing the hour).

Getting it to work is more important than jQuery stuff, but thank you very much for letting me know that people are working on this issue too :-).

jhedstrom’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Closing as duplicate of issues mentioned in #3.