Maybe something like:<br><br>rule "Prix premier semestre"<br> when<br> p1 : Produit( eval(dDeb.isBefore(new Date(2010,1,1) ) ) )<br> then<br> p1.setPrix( 10 );<br>
update( p1 );<br>end<br><br>Obviously you'll have to import whatever type of date you're using and change the call to the constructor to match.<br><br>I may be wrong but I think you need to use eval here because you want to create the comparison date within the rule. If you had already created the date using "<" would be fine:<br>
<br>rule "Prix premier semestre"<br>
when<br>
p1 : Produit( dateProperty1 < dateProperty2 )<br>
then<br>
p1.setPrix( 10 );<br>
update( p1 );<br>
end<br>
<br><br><div class="gmail_quote">2010/3/8 Bertrand Grottier <span dir="ltr"><<a href="mailto:b_grottier@hotmail.com">b_grottier@hotmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>
Hello,<br>Ok, I understand the problem. dDeb is indeed a Date type.<br>What is the proper/simplest way to achieve such a comparison ?<br>Thank you in advance for your help.<br>Regards,<br>Benoît<br><br><hr>Date: Thu, 4 Mar 2010 10:01:23 +0000<br>
From: <a href="mailto:ejdiggins@gmail.com" target="_blank">ejdiggins@gmail.com</a><br>To: <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>Subject: Re: [rules-users] Problem with date<div>
<div></div><div class="h5"><br><br>Hi,<br><br>What is the type of the dDeb field? It looks like you're trying to check if a date is less than a string.<br><br>Enda<br><br><div>2010/3/3 Bertrand Grottier <span dir="ltr"><<a href="mailto:b_grottier@hotmail.com" target="_blank">b_grottier@hotmail.com</a>></span><br>
<blockquote style="padding-left: 1ex;">
<div>
Dear all,<br><br>I am a newbie with Drools (Drools 5). I just want to make a date comparison but failed until now. Here is my drl file :<br><br>package com.sample<br> <br>import com.sample.DroolsTest.Produit;<br><br> <br>
rule "Prix premier semestre"<br> when<br> p1 : Produit( dDeb < "01-Jan-2010" )<br> then<br> p1.setPrix( 10 );<br> update( p1 );<br>end<br><br>I get a build error in Eclipse : Unable to create restriction.<br>
<br>This must be an obvious problem but I am struggling for a while now.<br><br>Any help would be appreciated.<br><br>Benoit<br>                                            <br><hr>Commander un cadeau en ligne discrètement? <a href="http://clk.atdmt.com/FRM/go/207186971/direct/01/" target="_blank">Voir la solution offerte par Internet Explorer8</a></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><br><br clear="all"><br>-- <br>Enda J Diggins<br>                                            <br></div></div><hr>Envie de naviguer sur Internet sans laisser de trace? <a href="http://clk.atdmt.com/FRM/go/207186970/direct/01/" target="_blank">La solution avec Internet Explorer 8</a></div>
<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Enda J Diggins<br>