Filtering a node by post date using an Offset value type and a value such as "-2 hours" produces the following SQL which fails to filter by date:
WHERE (term_node.tid = 132) AND (node.status <> 0) AND (node.created < ***CURRENT_TIME***-7200)
The asterisks appear to be causing the problem and are inserted by code in the 'op_between' function in the views_handler_filter_date.inc file in views>handlers directory. Removing the asterisks from "CURRENT_TIME" corrects the problem.
I've attached a patch to fix the code.
| Comment | File | Size | Author |
|---|---|---|---|
| views_filter_date_current_time.patch | 1.16 KB | james marks |
Comments
Comment #1
merlinofchaos commentedThe asterisks are a placeholder used by Views to substitute real values later on. See hook_views_query_substitutions
Comment #2
james marks commentedPatch above corrects ***CURRENT_TIME*** to CURRENT_TIME but, on closer examination of results, function still does not filter properly. Still working on it.
Comment #3
james marks commentedOk. Sorry about that.
Working on this because filtering nodes by post date appears not to work correctly. I'm getting all nodes returned rather than those whose post date match the filter criteria.
James
Comment #4
orfils commentedReplace CURRENT_TIME by CURRENT_DATE and for me it works