I'm trying to build a view that includes an argument that uses the Date API to allow filtering by date range on node.created. I want the filter to be "from 2011-06-28 through [TODAY]" inclusive. Granularity for the date argument is set to "day."

The url for my view is http://insights.wri.org/feed/all/20110628--@, where the path is "feed" the 1st argument is a wildcard, and the 2nd argument is a date range.

The query either works correctly or fails, depending on what time it is run! I'm trying to read through the module code to figure out what's going on, and having a thick time of it.

If I preview the view after ~10am EDT, the WHERE clause in question looks like this:

WHERE ((ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-14400)) <= '2011-07-28 10:17:58'
AND ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-14400)) >= '2011-06-28 00:00:00'))

But before ~10am (say 9:17), the WHERE clause looks like this (note the 00:00:00, even though it's 9:17):

WHERE ((ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-14400)) <= '2011-07-28 00:00:00'
AND ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-14400)) >= '2011-06-28 00:00:00'))

OTOH, If I use http://insights.wri.org/feed/all/20110628--20110728, I get an entirely different WHERE clause, which looks like the one I actually want.

WHERE ((DATE_FORMAT(ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-14400)), '%Y-%m-%d') <= '2011-07-28'
AND DATE_FORMAT(ADDTIME(FROM_UNIXTIME(node.created), SEC_TO_TIME(-14400)), '%Y-%m-%d') >= '2011-06-28'))

Just digging into date_api_argument_handler.inc a bit it appears that date_api gets very confused on granularity if "@" is the 2nd argument in a range.

My workaround for now is this:

http://insights.wri.org/feed/all/20110628--20501231

Comments

damienmckenna’s picture

Status: Active » Closed (won't fix)

Unfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.