Currently (5.2.0, but not <= 5.1.1) you can do:

rule future
when
    Date( $t: time ) from new Date()
    $p: Person( $dob: dob after[0] $t )
then
    System.out.println( $p.getName() + " not born yet." );
end

There are indeed some restrictions w.r.t. the use of temporal operators but
comparing Date/long field to Date/long field is OK.

(@Lisa: You realize that new Date() is somewhat unprecise when used to mean "today".)

-W

On 29 June 2011 01:04, lhorton <LHorton@abclegal.com> wrote:
Interesting.  I tried to use this syntax to find out if a date is older than
"now" using this source:

$p2: Person( $dob2: dob before[3d] new Date() )

but I get and exception: org.drools.RuntimeDroolsException: The 'before'
operator can only be used to compare one event to another, and never to
compare to literal constraints.

any idea how to compare to "new Date()"?  I had already written a function
to do this date comparison, but will use the Drools syntax instead if I can
get this to work.

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-Date-arithmetic-in-when-part-tp3118246p3119793.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users