I have a content type that contains a date field with from and to components. I'd like to create a view where for a given day all nodes are returned where that day falls between from and to. In previous versions of views, I could create a view with an argument based on that field, and the views query would be created such that only nodes where the argument was between the from and to components would be returned. I got the behavior I was after by default. Here's the relevant bit from a query (views 7.x-3.0-alpha1):
DATE_FORMAT(STR_TO_DATE(field_data_field_exh_dates.field_exh_dates_value, '%Y-%m-%dT%T'), '%Y-%m-%d') <= '2011-07-13' AND DATE_FORMAT(STR_TO_DATE(field_data_field_exh_dates.field_exh_dates_value2, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2011-07-13'
In the latest views (7.x-3.x-dev) with the same argument structure, the query has changed so that only a date equal to the from value is returned:
DATE_FORMAT(STR_TO_DATE(field_data_field_exh_dates.field_exh_dates_value, '%Y-%m-%dT%T'), '%Y-%m-%d') = '2011-07-13') )
If this is the intended behavior for views now, any suggestions on how to accomplish what I had before?
Thanks in advance.
Comments
Comment #1
merlinofchaos commentedComment #2
yskel commentedThanks - didn't realize this was a date issue. Just to confirm, I am working with Date 7.x-2.x-dev.
Comment #3
karens commentedThe new query will produce the right results. The less than/ greater than is really only need for week queries, for all others looking for dates that have a match based on the granularity will produce the right results, i.e. if the granularity is 'day', we can check that the value formated as Y-M-D = the date we are checking for. If you want to find dates that match only the month, you set the granularity to 'month' and the format is changed to Y-M.
Comment #4
yskel commentedIn my particular case, I have programs that span many days/weeks/months, and for a given day, I'd like to see which of the ongoing programs are available. So, the date 7/13/2011 passed as a views argument/contextual filter should return a program that started 4/15/2011 and ends 8/26/2011.
It sounds like my particular use case just happened to fit the behavior of Date prior to this update. Any suggestions on how I should proceed?
Thanks!
EDIT: Forgot I had opened an issue on this a while back: #1064808: Sort between two dates in views. Sorry for the dupe. Per instructions in that thread, I'll update to latest dev and see if this issue has been addressed.