<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div>In Drools 5 I'm passing in two global Date objects and need to find the difference in days between them.&nbsp; I've discovered that the function parameters (fromDate and toDate in my case) are null in the condition when the function is called, but when the function is called in the consequence they have values.&nbsp; I can see that because the output of the following rule is:</div><div>fromDate is null<br>toDate is null<br></div><div>I'm in dateDiff and the date diff is: 14</div><div><br></div><div>I'm guessing that Drools doesn't make globals t available at the point that I need them.&nbsp; Can anyone confirm this and offer a solution?<br></div><div><br></div><div>Here is the rule file itself:</div><div><br></div><div>import java.util.Date;<br>import org.joda.time.DateMidnight;<br>import
 org.joda.time.Days;</div><div><br></div><div>global java.util.Date fromDate;<br>global java.util.Date toDate;<br><br><br>rule "dateDiff"<br>dialect "mvel"<br>&nbsp;&nbsp;&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eval(getDaysBetweenStartAndEndDate(fromDate, toDate) &lt; 10)<br>&nbsp;&nbsp;&nbsp;&nbsp; then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( "I'm in dateDiff and the date diff is: " +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getDaysBetweenStartAndEndDate(fromDate, toDate));&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>end <br><br><br>function int getDaysBetweenStartAndEndDate(Date fromDate, Date toDate) {</div><div>&nbsp; &nbsp; if (fromDate==null) System.out.println("fromDate is null");<br>&nbsp;&nbsp;&nbsp; if (toDate==null) System.out.println("toDate is null");<br>&nbsp; return
 Days.daysBetween(new DateMidnight(fromDate), new DateMidnight(toDate)).getDays();<br>} <br></div></div></body></html>