Hello,
Problem
When using Views and an exposed date filter with a granularity set to 'Month' (so that only 'Year' and 'Month' get selected), the filter does not work - it runs the filter, but instead uses the current date rather than the date asked for.
Note that the second time the filter is run, then it works better. When testing this issue, it is best to reload the page afresh (without submitting any searches) between tests.
Analysis
With the granularity set to Month, the search form initialy sets the day to '0' (as a hidden value). This causes 'date_is_valid' to return false ; and thus the search uses the default value (current date) instead.
I'm not sure what happens the second time you run the filter - the default value for day is not '0' anymore, but seems to be the current day
Thanks for this module :) Please let me know if you need any extra information, or if I can help you sort out this issue. I'll set my filter's granularity to day for now :)
Comments
Comment #1
Alice Heaton commentedWith a bit more detail :
In the class date_api_filter_handler, the method date_filter calls date_make_date (on line 369 of date_api_filter_handler.inc as of rc4).
date_make_date returns the current date because, as per the original bug report, date_is_value returns false.
Hope this is a bit more helpful.
Comment #2
karens commentedI've committed some changes that I think get this working right.
Comment #3
raspberryman commentedHi Karen,
Testing with DRUPAL-6--2 that you committed today...
The changes work when:
However, if I make any further changes after step #3 to the filter configuration page, such as changing the absolute date or exposing the filter, the bug described above resumes: "it runs the filter, but instead uses the current date rather than the date asked for"
Thanks for your awesomeness!
Comment #4
raspberryman commentedMore info...
When I set the granularity to Day, the Views Filters list reads:
Date: Date Content: My Date Field - (field_mydatefield) = 2008-12-11 00:00:00When I change the granularity to Month, the list reads:
Date: Date Content: My Date Field - (field_mydatefield) = 2008-12-11 00:00:00And the filter works!
When I change the filter configuration page in any way, however, the list reads:
Date: Date Content: My Date Field - (field_mydatefield) = 2008-12-00 00:00:00The day is set to '00'. At this point, the filter breaks, and the query uses the current date instead.
Comment #5
raspberryman commentedJust out of curiosity, I tested with today's DRUPAL-6--2. Still no luck.
Comment #6
raspberryman commentedThis is my temporary hack to get things working.
I must admit that the date module confuses me and I commend Karen for being able to keep all these details straight :)
Comment #7
karens commentedI committed a number of fixes to the filter this morning and this should be working.
Comment #9
vinoth.3v commentedHI
have any possibilities to filter out only by "Month" (with out Year) ?
because it may be use full to display this month D.O.B s??
Thanks
Comment #10
zoo commented@#9
Hello, so did you get it working filtering only by month?
Could you please tell how here: http://drupal.org/node/896362?
Thank you, zoo