By James Taylor on Aug 29, 2012
I have been working with decision tables for some time but have never had a scenario where I need to compare dates. The use case was to check if a persons membership had expired. I didn't think much of it till I started to develop it. The first trap I feel into was trying to create ranges and bucket sets. The other trap I fell into was not converting the date field to a complete date. This may seem obvious to most people but my Google searches came up with nothing so I thought I would create a quick post.
I assume everyone knows how to create a decision table so I'm not going to go through those steps. The prerequisite for this post is to have a decision table with a payload that has a date field. This filed must have the date in the following format YYYY-MM-DDThh:mm:ss.
- Create a new condition in your decision table
- Right-click on the condition to edit it and select the expression builder
- In the expression builder, select the Functions tab.
- Expand the CurrentDate file and select date, and click Insert Into Expression button.
- In the Expression Builder you need to create an expression that will return true or false, add the operation <= after the CurrentDate.date
- In my scenario my date field is memberExpire, Navigate to your date field and expand, select toGregorianCalendar().
- Your expression will look something like this, click OK to get back to the decision table
- Now its just a matter of checking if the value is true or false.
Simple when you know how :-)