Number of days between 2 dates?

Hi all, I want to set up a condition that depends on the number of days between 2 date global variables... is this currently possible?

Basically I want to do something if it's been x number of days since something happened.

You can prevent something from happening for x number of days that you calculate between two variables. Would that be sufficient? Here's an example using local variables. Obviously, you'd need to add some actions between the Wait for event: motion active and PB True.

Using hub variables, the variable logic could be a separate rule.

For the fun of it, I did a proof of concept rule (to calculate the days) and it worked. It would be easy enough to extend the logic based upon DaysElapsed from there.

1 Like

Thank you both, I'll give this a try.

Something funky going on, that approach is not working for me. The only difference I see is I am using 2 global variables (LastWindowFanRunDate and CurrentDate) and your example is not.

They're both type DateTime


Can you see if it working using local variables instead of hub variables?

Yes it works as expected with local vars. Must be a bug. Where and how do we report bugs?

@support_team It looks like we have a bug here doing date math with global date variables.

My info is:

1 Like

Is there a reason to use global variables? If it's only used in one rule it isn't necessary. Local works fine.

Yes, unless there's another way to determine the last time a device turned on or off from within a rule.

What are you using to set the dates? Normally you should be getting a format string that parses using yyyy-MM-dd’T’hh:mm:ss:SSSZ but the error is showing a current date that would parse using a non-standard yyyy-MM-ddhh:mm:ss:SSSZ

In the example shown I'm setting the date using "set to current date", the failing example is Jan 28, 2023

Let’s ask @bravenel about this as it would appear to be a RM issue with the setting of the date.

The error is caused by using a date without time in the Set to minutes of difference. Now, it should not be throwing an error for that, and I will track that down. This would work if you used Current Date and Time instead of Current Date in the first action.


This bug has been found and fixed, for the next release... When a date is chosen without time, it fills in midnight.


@bravenel Thanks for your tireless effort to keep Rules Manager managing rules better and better. :smile:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.