<br>&nbsp;&nbsp;&nbsp; Miguel,<br><br>&nbsp;&nbsp;&nbsp; You must be careful with the concept of &quot;current date&quot; when writing rules in RETE: remember that RETE works in 2 stages:<br><br>1. at &quot;insert&quot; time, all the rule constraints are evaluated.
<br>2. at &quot;fire&quot; time, the active rules are simply executed.<br><br>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; So, having said all that, I suggest you use either a fact or a global to represent your &quot;clock&quot;, 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>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; Edson<br><br><br>
<div><span class="gmail_quote">2007/10/26, Miguel Figueiredo &lt;<a href="mailto:mfigueiredo@telbit.pt">mfigueiredo@telbit.pt</a>&gt;:</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fact : MyFact(date : fact, eval(timediff(date) &gt; 10));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(&quot;Greater than 10 seconds&quot;);
<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>&nbsp;&nbsp;Edson Tirelli<br>&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646
<br>&nbsp;&nbsp;JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>