I have a content type with a CCK Integer field that contains a four digit number, which represents a year but for reasons I don't want to get into can't be held in a date field.

I would like to filter a view by this field relative to the present.

I'd love to be able to just put YEAR(CURDATE()) in a filter option field, but this doesn't work. It looks like it's getting quoted in the WHERE clause (as one would expect).

querying the database directly:
WHERE node_data_field_class_of.field_class_of_value < 'YEAR(CURDATE())' doesn't work
WHERE node_data_field_class_of.field_class_of_value < YEAR(CURDATE()) does work

Is it possible to add something to the view (preferably using the UI) to add to the WHERE statement? I tried sticking $query->add_where("node_data_field_class_of.field_class_of_value < YEAR(CURDATE())") in the argument's PHP box, but no dice.

Please advise. Love Love LOVE views, otherwise.

Comments

sun’s picture

Status: Active » Closed (won't fix)

Sorry, unfortunately this support request is way too specific. Please have a look at the issue queue - Views maintainers are buried already. You might want to try to get further support at http://drupal.org/support.