How About a Date with InRule?

ML

Mark Lonsway

09/29/2014

A date gone bad can be a funny thing – it can be the source of a story for the ages or a memorable movie bit. But a bad date check in business logic…not so funny, and more than likely it will not result in a “bank error in your favor.”

Consider the following date expression:

This seemingly innocuous date expression represents a number of considerations for a rule author who is handling date logic. The following series of test scenarios based on the above expression help demonstrate a few of the more notable considerations.

Scenario #1

NEED TO KNOW #1

The IsBetween function is inclusive and does not differentiate which date comes first, the Effective Date or the Expiration Date.

Scenario #2

NEED TO KNOW #2

A null or empty date will resolve to 1/2/0001 for the purpose of date comparison.

Scenario #3

NEED TO KNOW #3

Be aware of date times that could influence date checking. In the above scenario if the dates being checked were actually DateTime fields (which occurs more than you might think), the time could throw off the date check.

How to handle these scenarios so your date doesn’t go south?

Vocabulary to the rescue, of course! The below “is within contract dates” custom vocabulary is an example of a template that can be employed to mitigate the unexpected behaviors described in the preceding test scenarios.

Moving on down the road, relying on this or similar custom vocabulary templates should help ensure that your dates with InRule go silky smooth.

InRule for JavaScript | inrule said: "[…] couple of weeks ago we announced availability of InRule® for JavaScript through an early adopter program. To our knowledge this is […]".
Dynamic Surveys in Dynamics CRM Part II: Managing Dependencies | inrule said: "[…] this post makes extensive references to my preceding post, Surveys in Dynamics CRM Part I: Don’t Be a Monkey With Your Survey. If you are the type of person who likes to get the full story, you should go back and read the […]".
Josh Elster said: "In the time since this post was published, I've added (via a PR) full Windows Containers example code, DOCKERFILEs and scripts. They share common ancestry with the GH Gists I posted earlier, but are more up-to-date and tested. Here's a direct link to that sub-folder: https://github.com/InRule/Samples/tree/master/Developer%20Samples/WindowsContainers Now that our Samples repository is public, feel free to file Issues if you have problems or features you'd like to see implemented. If you have something you'd like to contribute, then by all means do so! The contributor guidelines and process are listed in the root of the repository. Enjoy! I'll update the body of the post as well with this link.".