I came across a sample where I did this before. Remember that this is FormCalc. The function returns the number of days since the epoch not the number of milliseconds (thats what Javascript does). Here is the command I used:
xfa.host.messageBox(Date2Num(EndDate.rawValue, "YYYY-MM-DD") - Date2Num(StartDate.rawValue, "YYYY-MM-DD"))