Rule to check if a date value is a specific day of the week I want to set a rule which checks a date of format "2014-09-24 08:43:39" is a Monday using the data comparison rule. I have tried to manipulate the data selector for the date using the ":custom:N" format however data comparison wont accept it.
I'm trying to do it from within the rules module as my PHP is a bit limited.
Any ideas?
Thanks
Adrian
I had myself many troubles with Rules and dates too. There are several open issues in Rules about dates. So the solution that I offer is very cumbersome and to be honest I don't like it too, but it seems to be the only thing to work. Improvements are of course welcome. Maybe there is also some module which I miss.

Note that this is about Rules ver. 7.x-2.7. The solution involves both some PHP code and components.

So the first issue at hand is that it seems Rules cannot change the format of a date variable in a data comparison, or to properly convert the data type.

Therefore I am using a rule to get the weekday from the variable, then pass it to a component as a variable (integer). In that component I can easily do a data comparison for the interger and procedd with any actions.

In order to get the weekday, I create an action "Add a variable". In there, I use some PHP code in order to directly get the week day. Here is the second issue: Rules do not seem to properly expose the variables in PHP. Therefore I specify the type of the variable as text, and then I specify the value using one of the replacement patterns in the direct input mode (otherwise a date will not be available in the data selection mode). Now we have the date as a string in a variable. Let name the variable variable_added.

The second action is to "Set a data value". In there, you specify:

&lt;?php
$datetime = new DateTime(DateTime::createFromFormat('D, d/m/Y - H:i', $variable_added));
return $datetime-&gt;format('w');
?&gt;


We create a DateTime object from a hard-coded format. This has to be the Drupal long date format which Rules seem to use for their date formatting. There got to be an API function that returns the current format which atm I miss, and so we have it hard coded to get us going. Replace this with your installation's custom format from /admin/config/regional/date-time, also consult this. Then we use DateTime::format to get the day number. 

So now we have the day number as a string. The third action would be to convert the above variable to an integer, and then in a fourth action you would call the rules component passing on the converted variable along with any other variables you would need.

Appendix: My test case rule export.

{ "rules_test_date" : {
    "LABEL" : "Test date",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "php" ],
    "ON" : { "cron" : [] },
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "[site:current-date]" },
          "PROVIDE" : { "variable_added" : { "variable_added" : "Added variable" } }
        }
      },
      { "data_set" : {
          "data" : [ "variable-added" ],
          "value" : "\u003C?php\r\n$datetime = new DateTime(DateTime::createFromFormat(\u0027D, d\/m\/Y - H:i\u0027, $variable_added));\r\nreturn $datetime-\u003Eformat(\u0027w\u0027);\r\n?\u003E"
        }
      },
      { "drupal_message" : { "message" : [ "variable-added" ] } },
      { "data_convert" : {
          "USING" : { "type" : "integer", "value" : [ "variable-added" ] },
          "PROVIDE" : { "conversion_result" : { "conversion_result" : "Conversion result" } }
        }
      }
    ]
  }
}