Avatar

Correct answer by
Level 10

Hi,

I would recommend using FormCalc for anything to do with dates. The process is fairly straight forward, you convert each date to a number and subtract them. In the script I have wrapped the calculation in an if statement to check that the dates are correct first:

if (startDate == null or finishDate == null ) then

     $ = null

elseif (startDate > finishDate) then

     xfa.host.messageBox("Please check the start and finish dates, as there appears to be an error", "Dates")

     $ = null

else

     $ = Date2Num(finishDate, "YYYY-MM-DD", "en_IE") - Date2Num(startDate, "YYYY-MM-DD", "en_IE")

endif

Good luck with the presentation,

Niall

View solution in original post