So I did a little practice with what you have and here are two ways that worked on my end to bypass the inclusive difference that Thom mentioned:
- The first is using Thom Parker's script from his tutorial - again, it seems that when put together the Math.round and Math.field in this variable --->> var days = Math.round(Math.ceil(diff/oneDay)); get the results that you are looking for. I've changed the field names to what you have in your original script, so if you wan't to copy it and try it, please go ahead.
var dd = this.getField("Begin").value;
var rd = this.getField("End").value;
if(dd.length && rd.length)
{
var d1 = util.scand("mm/dd/yy",dd);
var d2 = util.scand("mm/dd/yy",rd);
var diff = dateEnd.getTime() - dateStart.getTime();
var oneDay = 24 * 60 * 60 * 1000;
var days = Math.round(Math.ceil(diff/oneDay));
event.value = days;
}
- The second work around is adding by 1 in the the event value like Thom suggested to you----------->>> event.value = Math.round((diff / 60 / 60) / 24)+1; I am using your script in this example which you can also try it out and see for yourself:
var dd = this.getField("Begin").value;
var rd = this.getField("End").value;
var d1 = util.scand("mm/dd/yy", dd);
var d2 = util.scand("mm/dd/yy", rd);
var diff = (d2.valueOf() - d1.valueOf()) / 1000;
event.value = Math.round((diff / 60 / 60) / 24)+1;