<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Thank you for your help. I tried the solution you proposed but encountered the following error message:<br>[10,27]: [ERR 101] Line 10:27 no viable alternative at input 'new' in rule "Prix premier semestre" in pattern Produit<br>[10,36]: [ERR 102] Line 10:36 mismatched input '2010' expecting ')' in rule "Prix premier semestre" in pattern Date<br><br>Eventually, I had to adapt the rule in the following way:<br>rule "Prix premier semestre"<br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $p1 : Produit(id == 1)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval ($p1.dDeb.before(new Date(2010,3,1) ) )<br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $p1.setId(2) ; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $p1.setPrix(10) ;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; update( $p1 );<br>end<br><br>The test on the id shouldn't be necessary but I can't make it work without.<br>So, the current version is not very clean. Have you got an idea ?<br><br>Regards,<br>Benoît<br><br><hr id="stopSpelling">Date: Mon, 8 Mar 2010 10:09:20 +0000<br>From: ejdiggins@gmail.com<br>To: rules-users@lists.jboss.org<br>Subject: Re: [rules-users] Problem with date<br><br>Maybe something like:<br><br>rule "Prix premier semestre"<br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p1 : Produit( eval(dDeb.isBefore(new Date(2010,1,1) ) ) )<br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p1.setPrix( 10 );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 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 "&lt;" would be fine:<br>
<br>rule "Prix premier semestre"<br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p1 : Produit( dateProperty1 &lt; dateProperty2 )<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p1.setPrix( 10 );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
 update( p1 );<br>
end<br>
<br><br><div class="ecxgmail_quote">2010/3/8 Bertrand Grottier <span dir="ltr">&lt;<a href="mailto:b_grottier@hotmail.com">b_grottier@hotmail.com</a>&gt;</span><br><blockquote class="ecxgmail_quote" style="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">ejdiggins@gmail.com</a><br>To: <a href="mailto:rules-users@lists.jboss.org">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">&lt;<a href="mailto:b_grottier@hotmail.com">b_grottier@hotmail.com</a>&gt;</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>&nbsp;<br>import com.sample.DroolsTest.Produit;<br><br>&nbsp;<br>

rule "Prix premier semestre"<br>&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p1 : Produit( dDeb &lt; "01-Jan-2010" )<br>&nbsp;&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p1.setPrix( 10 );<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 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/">Voir la solution offerte par Internet Explorer8</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">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/">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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Enda J Diggins<br>                                               <br /><hr />Envie de naviguer sur Internet sans laisser de trace? <a href='http://clk.atdmt.com/FRM/go/207186970/direct/01/' target='_new'>La solution avec Internet Explorer 8</a></body>
</html>