Not sure if it would help, but we have gotten around some Date comparison problems by using the getTime() method on the Date objects. Basically, it returns time in ms since 1970 (which works fine for comparison).
I'm not sure if you can create a new Date object in the LHS of the rule. If you can, that date is set to now. So if you do that, you should be able to add 2 years in ms (2L * 365L * 24L * 60L * 60L * 1000L) and compare that with your date. If you can't create it in the LHS, you could always assert a current data object to represent the Date either now or 2 years from now. That being said, couldn't you do something like: when # $todaysDate either from asserted Date object for now, or a new Date() if can be done Reference(fromDate.time > ($todaysDate.time - (2L * 365L * 24L * 60L * 60L * 1000L))) then <Output error> end BrianKE wrote: > > I need to code a rule which checks that the begin date for an object is at > least two years ago (from todays date). Is there an easy way to code this > within Drools rule, something like: > > when > Reference(fromDate > (todaysDate - 2 years)) > then > <Output error> > end > > Thanks in advance, > Brian Enderle > > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > -- View this message in context: http://www.nabble.com/Date-for-2-years-ago-tf4471163.html#a12784331 Sent from the drools - user mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users