[rules-users] Matching time diff

Miguel Figueiredo mfigueiredo at telbit.pt
Fri Oct 26 13:12:00 EDT 2007


Hi listers,

I have a fact MyFact that has a Date field in it, and I want to check if the 
difference between this date and the current date is greater than 10 seconds:

The function timediff() returns the difference in seconds between a date and 
the current date.

Rule:

rule myRule
	when
		fact : MyFact(date : fact, eval(timediff(date) > 10));
	then
		System.out.println("Greater than 10 seconds");
end

When I fire the rules, and the difference is less than 10 seconds nothing 
happens. The next time that I fire the rules and the difference is greater 
than 10 seconds nothing happens as well.

How can I make this work?

Best regards,

Miguel



More information about the rules-users mailing list