· Sep 29, 2017

interval in rule editor

Hi,in my rule  i want to compare a value wich i extract from a file if it's inside in my interval values or no, example:


is there any function in rule editor that allow me to do this.


Discussion (2)0
Log in or sign up to continue


If I understand you correctly, I think you want to know whether there is a function that you can invoke, from the condition field of a Business rule, that checks if a given date is in between two other dates.

If you want to see what functions are available, the best way is to get assistance from the Expression editor (that is invoked when you double-click in the Condition field, or click 'fx', on the main Business Rules definition window when the condition field is in focus)

Whilst in the Expression Editor, clicking 'fx' again, will list the available functions, and the editor will help you through the process of building an expression that includes the use of these functions, and wrapping them around AND, OR and other operators.

I would suspect, however, that by default, we do not supply an in-built Business Rules function for your current scenario - however - (and I think this is a powerful feature), you can create whatever custom function and add these to the ones already available.   When you create your function, this will appear in the Expression Editor and can be used just as if it came with Ensemble.

Building your own function for this purpose is easy, it is just a class that extends Ens.Rule.FunctionSet, and must follow some basic rules.  See the documentation here: 

Your function would take 3 arguments, value, date1 and date2 to determine whether the date in 'value' is in between date1 and date2.  Here I'm assuming the date format is CCYYMMDD, and I'm converting the incoming date to a numeric $horolog date, using the $zdh (or $zdateh) function.  Change accordingly if your date format is different.

Class User.CustomFunctions Extends Ens.Rule.FunctionSet

/// take 3 date values in CCYYMMDD format, (value, date1 and date2) and verify if value falls between date1 and date2
ClassMethod DateBetween(value, date1, date2) As %Boolean
if ($zdh(date1,8)<$zdh(value,8)) && ($zdh(value,8)<$zdh(date2,8)) quit 1
quit 0


Defining a class like the sample above in your Ensemble-enabled namespace and compiling it, will expose this function (and the comment after the 3 '/') to the Ensemble Expression editor like any other function that already comes with Ensemble.

Hope this helps.