<br>&nbsp;&nbsp; Michael,<br><br>&nbsp;&nbsp; Just an important note, that sometimes is overlooked by users: <br><br>*** Inline evals and return value predicates MUST be time constant ***<br><br>&nbsp;&nbsp; It means that an inline eval() must return the exact same value if it is executed now, or in 5 minutes from now, or whatever. So, it is not advisable for you to write the constraint as you did.<br>
&nbsp;&nbsp; The correct way would be to use a top level eval() that does not suffer from the same restriction:<br><br>&nbsp;
 MyFact( $value : value )<br>&nbsp; eval( $value.before(DateHelper.getModifiedDate(-6, &quot;MONTHS&quot;)))<br><br>&nbsp;&nbsp;&nbsp; The use of a non-time-constant inline eval (or return value predicates) causes unpredictable behavior in the engine.<br>
<br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson<br><br><br><div class="gmail_quote">2008/5/7 Michael B. &lt;<a href="mailto:michael.bain@mckesson.com">michael.bain@mckesson.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I dont know if this is still outstanding since the original post seems to<br>
have disappeared, but this is what I did during my proof of concept that I<br>
am going through:<br>
<br>
In a helper class (i.e. DateHelper) I had this method:<br>
<br>
 &nbsp; &nbsp;public static Date getModifiedDate(int amount, String unit) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Calendar cal = Calendar.getInstance();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;cal.setTime(getNow());<br>
 &nbsp; &nbsp; &nbsp; &nbsp;BusinessObject.stripTime(cal);<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;int calUnit = Calendar.DAY_OF_YEAR;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (UNIT_MONTHS.equals(unit))<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;calUnit = Calendar.MONTH;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;else if (UNIT_YEARS.equals(unit))<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;calUnit = Calendar.YEAR;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;cal.add(calUnit, amount);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;return cal.getTime();<br>
 &nbsp; &nbsp;}<br>
<br>
Then in my rule it would be like this:<br>
<br>
 &nbsp;MyFact( eval( value.before(DateHelper.getModifiedDate(-6, &quot;MONTHS&quot;))))<br>
<br>
Hope that helps.<br>
<br>
-----<br>
Drools Noob since 5/2008<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/Re%3A-Date-arithmetic-in--%C3%A2%C2%80%C2%9Cwhen%C3%A2%C2%80%C2%9D-session-tp17103754p17106177.html" target="_blank">http://www.nabble.com/Re%3A-Date-arithmetic-in--%C3%A2%C2%80%C2%9Cwhen%C3%A2%C2%80%C2%9D-session-tp17103754p17106177.html</a><br>

</font><div><div></div><div class="Wj3C7c">Sent from the drools - user mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>