Hello,

I'm trying to add a filter in a view which is based on two fields to be compared with now() value.
I suppose this is a quite easy requirement...but it doesn't work unfortunately.

Looking the SQL query (produced by view editing fnctionalities and printed hereafter) indeed values are compared with ''2009-01-01'.
I presume this should be a now() value. Looks like now() relies only on year, not month and day.

My version is 6.10 (had same problem with 6.9).

Thanks for any clarification or clue.
Bye,
Bruno

SELECT node.nid AS nid,
node.title AS node_title,
node_data_field_date.field_locationcck_lid AS node_data_field_date_field_locationcck_lid,
node_data_field_date.nid AS node_data_field_date_nid,
node.type AS node_type,
node_data_field_date.field_date_value AS node_data_field_date_field_date_value,
node_data_field_date.field_date_value2 AS node_data_field_date_field_date_value2
FROM node node
LEFT JOIN content_type_event_type node_data_field_date ON node.vid = node_data_field_date.vid
WHERE ((DATE_FORMAT(STR_TO_DATE(node_data_field_date.field_date_value, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2009-01-01') AND (DATE_FORMAT(STR_TO_DATE(node_data_field_date.field_date_value2, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2009-01-01'))
AND (node.type in ('event_type'))
ORDER BY node_data_field_date_field_date_value ASC

Edited by WorldFallz - added '[Solved]' to title.

Comments

phaer’s picture

I got exactly the same problem. All modules are up to date.

bcostacurta’s picture

I'll post to the 'issue' forum this problem.

chris.mccreery’s picture

Same issue for me too. If I set the Relative Value to 'now' it doesn't filter the items. If I manually set the date with the Absolute Value then everything works fine. The 'now' doesn't seem to translate to the actual date. I get the following query in the Views preview.

SELECT node.nid AS nid,
   node_data_field_date.field_date_value AS node_data_field_date_field_date_value
 FROM node node 
 LEFT JOIN content_type_event node_data_field_date ON node.vid = node_data_field_date.vid
 WHERE node.type in ('event')
   ORDER BY node_data_field_date_field_date_value ASC

Thanks

WorldFallz’s picture

FYI -- When I encountered this problem it was because of this issue and upgrading to the latest DEV version of the date module fixed it.

bcostacurta’s picture

Dear WorldFallz,
could you be more precise ?
Which version (apparently correct) do you currently use ?

Thanks for details.
Bye,
Bruno

WorldFallz’s picture

Don't over think it-- the 'latest dev' means exactly that. You can download it directly from the project page under "Development Snapshots".

Also, I somehow originally linked to the wrong issue in my comment above (i fixed the link). See http://drupal.org/node/386406#comment-1349776 for more detailed version info.

bcostacurta’s picture

Thanks WorldFallz.
Indeed the latest dev. version (currently 6.x-2.x-dev) to be download from Development Snapshot correct the 'now' function.

Bye,
Bruno

WorldFallz’s picture

Just an fyi--- it will always be '6.x-2.x-dev' ;-)

bcostacurta’s picture

Thanks for clarification ;-)
I think versions numbering are sometimes confusing but at least this development version works :-)
Bye.