1 Reply Latest reply on Apr 14, 2011 5:16 PM by Jason Sroka

    Comparing dates in Guvnor-authored rules

    Jason Sroka Newbie

      I am trying to write some rules that involve determining the date that I pull from a field in one table falls within a range specified by two values in another table.  I have been able to set up my Fact Model to reflect these various date fields with no problem.  I am using a SQL Server database and generated POJOs using Hibernate reverse engineering, then loaded the POJOs to create my fact model.  The fields in question are all "date" types in SQL Server.


      When I try to write my rule, it seems like Guvnor does not allow date comparisons other than "equal to", "not equal to", "matches", or "sounds like".  I was expecting that for date types, it would allow ">" (greater than, or after) and "<" (less than, or before) comparisons also.


      Is there a way to get simple greater than/less than (i.e. before/after) comparisons as conditions for a rule?  Do I need to use a different data type in SQL Server to enable those comparison operators?  Alternatively, is there some way to use "matches" combined with a formula (e.g. ">WeekStartDate" so the final condition becomes "Date matches(>WeekStartDate)" that implements this comparison correctly?


      Thanks in advance...



        • 1. Comparing dates in Guvnor-authored rules
          Jason Sroka Newbie

          I think I found a solution, though I haven't thoroughly tested to confirm this was the fix.


          I went back to the SQL Server DB and changed from using a Date field to using a Datetime field, and then I was able to see the additional comparators that included the 'less than or equal to' and the 'greater than or equal to' comparisons I was looking for.