Currently (5.2.0, but not <= 5.1.1) you can do:<br><br>rule future<br>when<br> Date( $t: time ) from new Date()<br> $p: Person( $dob: dob after[0] $t )<br>then<br> System.out.println( $p.getName() + " not born yet." );<br>
end<br><br>There are indeed some restrictions w.r.t. the use of temporal operators but<br>comparing Date/long field to Date/long field is OK.<br><br>(@Lisa: You realize that new Date() is somewhat unprecise when used to mean "today".)<br>
<br>-W<br><br><div class="gmail_quote">On 29 June 2011 01:04, lhorton <span dir="ltr"><<a href="mailto:LHorton@abclegal.com">LHorton@abclegal.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Interesting. I tried to use this syntax to find out if a date is older than<br>
"now" using this source:<br>
<br>
$p2: Person( $dob2: dob before[3d] new Date() )<br>
<br>
but I get and exception: org.drools.RuntimeDroolsException: The 'before'<br>
operator can only be used to compare one event to another, and never to<br>
compare to literal constraints.<br>
<br>
any idea how to compare to "new Date()"? I had already written a function<br>
to do this date comparison, but will use the Drools syntax instead if I can<br>
get this to work.<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/rules-users-Date-arithmetic-in-when-part-tp3118246p3119793.html" target="_blank">http://drools.46999.n3.nabble.com/rules-users-Date-arithmetic-in-when-part-tp3118246p3119793.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
</font><div><div></div><div class="h5">_______________________________________________<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>