Date field comparison in Rules I'm trying to check if a date field value has been changed on a node update. (Rules Drupal 7)

Here's my rule configuration:

    { "rules_node_update" : {
    "LABEL" : "Update",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_presave--expedient" : { "bundle" : "expedient" } },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node-unchanged" ], "field" : "field_tria" } },
      { "NOT data_is" : {
          "data" : [ "node-unchanged:field-tria" ],
          "value" : [ "node:field-tria" ]
        }
      }
    ],
    "DO" : [ { "drupal_message" : { "message" : "UPDATED DATE" } } ]
  }
}


Event: Before saving (i have already tried with node update)

NOT data comparison
Parameter: Data to compare: [node:field-tria], Data value: [node-unchanged:field-tria]

What i'am trying to do here is... IF the (new) date value IS NOT EQUAL to unchanged field value (old)... THEN do something. (like print message on screen)

The result of the data comparison returns always TRUE and don't know why.

Notes:


Having proven the suggested changes, the result remains the same. I edit a node, and whether I change the value of the "tria" field or not, it still returns true.
If I (temporary) OMIT the data comparison it shows the final message. Here's an example of what i'm getting with my setup: Edit a node of this content type, the node already has a date data in the "tria" field. Without making any changes, just save. It shows the message. If i change that field value to another and then save. It also shows the message. So, i think node-unchanged value must me empty because she's not doing the data comparison the right way.
Here is the debug of the variables after saving/updating a content : Debug value Parameter: Value to debug: [node-unchanged:field-tria] ... (Array, 1 element) 0 (Array, 6 elements) value (String, 19 characters ) 2001-01-10 01:00:00 value2 (String, 19 characters ) 2001-01-10 01:00:00 Debug value Parameter: Value to debug: [node:field-tria] ... (Array, 1 element) 0 (Array, 10 elements) value (String, 19 characters ) 2001-01-20 01:00:00 value2 (String, 19 characters ) 2001-01-20 01:00:00 Values are there, and they are different! as expected!
The rule evaluation log shows this once the node has been updated with different values:


The rule evaluation log shows this once the node has been updated with no changes on the values... just saved
Part 1 - Just to be sure

Add an extra Rules condition like "entity has field", related to that field-tria, before your existing Rule Condition where you do that data comparison.

If that doesn't seem to help, then (temporary) remove the data comparison, to make sure your message is shown for those scenarios as in your Rules Event / Condition (that the entity has that field). If you even don't get the message in this case, then something is really wrong with your rule (eg: you'd be using the wrong Rules Event).

Part 2 - Rules debugging needed

If the above doesn't help, I suggest you start some Rules debugging, as detailed in "How can I display the value of a variable inside a condition?", to get more details about why your rule doesn't seem to work as you'd want it to.

Part 3 - Why your data comparison cannot work

As per your additional comment "this is a multi value field": THAT pretty much explains why your rule seems to behave bizarre ... But sorry, it's rather that you're trying to make Rules do something (compare 2 values), without providing Rules all the info it needs.

If I was to show you 10 glasses of beer (each with their own label say), and I also show you another glass and ask you "is this other one the same?", then the predictable question that would come up is "as compared to which of those 10 glasses?". So that's similar to what's happening in your current rule.

How to move forward

Your Rules Event is pretty sure OK, but you're missing a crucial Rules Action: a Rules Loop. If you're not familiar with such loops, then I strongly recommend to have a look at the tutorial titled "Lists and loops".

In your case, you should add a loop related to that list of dates (which you confirmed to be a multi value field). After you do, you should iterate over each item in that list (= each date). And for each iteration you should then perform the "equivalent of the Rules Condition" you are trying to get to work, whereas you should be using the list item being processed in the current iteration step).

To be honest, I'm afraid that the above will get you closer to the complete solution, but the remaining challenge appears to be "how to specify the date value (a single one) that is to be compared with each of those date-list-items?". Correct me if I'm wrong, but your question is still not clear on that.

PS: this answer (cearly) relates to D7.