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.

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

The asterisks are a placeholder used by Views to substitute real values later on. See hook_views_query_substitutions

james marks’s picture

Status: Closed (won't fix) » Active

Patch above corrects ***CURRENT_TIME*** to CURRENT_TIME but, on closer examination of results, function still does not filter properly. Still working on it.

james marks’s picture

Status: Active » Closed (fixed)

Ok. 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

orfils’s picture

Replace CURRENT_TIME by CURRENT_DATE and for me it works