Here's my FormCalc version.
var numOfDays = Date2Num(endDate.rawValue,"YYYY-MM-DD") - Date2Num(startDate.rawValue,"YYYY-MM-DD")
if (numOfDays > 30) then
NumOfDays.rawValue = numOfDays - 30
xfa.resolveNode("NumOfDays.ui.#textEdit.border.fill.color").value = "255,0,0"
else
NumOfDays.rawValue = null
xfa.resolveNode("NumOfDays.ui.#textEdit.border.fill.color").value = "255,255,255"
endif
Steve