<br> Miguel,<br><br> You must be careful with the concept of "current date" when writing rules in RETE: remember that RETE works in 2 stages:<br><br>1. at "insert" time, all the rule constraints are evaluated.
<br>2. at "fire" time, the active rules are simply executed.<br><br> Also, note that using non-time constant expressions in an inline-eval is wrong and will give you unpredictable results. The only way to use non-time constant expressions is at a top level eval (not inline-eval).
<br> So, having said all that, I suggest you use either a fact or a global to represent your "clock", so that you have a way to control when and how the clock is updated and use this pseudo clock to constrain your facts.
<br><br> Also, we are working on supporting temporal constructs in drools as we speak, and as soon as we have that, we hope it will be a lot easier to write (safe) temporal constrained rules.<br><br> Edson<br><br><br>
<div><span class="gmail_quote">2007/10/26, Miguel Figueiredo <<a href="mailto:mfigueiredo@telbit.pt">mfigueiredo@telbit.pt</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi listers,<br><br>I have a fact MyFact that has a Date field in it, and I want to check if the<br>difference between this date and the current date is greater than 10 seconds:<br><br>The function timediff() returns the difference in seconds between a date and
<br>the current date.<br><br>Rule:<br><br>rule myRule<br> when<br> fact : MyFact(date : fact, eval(timediff(date) > 10));<br> then<br> System.out.println("Greater than 10 seconds");
<br>end<br><br>When I fire the rules, and the difference is less than 10 seconds nothing<br>happens. The next time that I fire the rules and the difference is greater<br>than 10 seconds nothing happens as well.<br><br>How can I make this work?
<br><br>Best regards,<br><br>Miguel<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">
https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<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>