Here is the code sample using VBScript. You need to call it from OnAfterChange event.
Sub UpdateDateDiff
Dim fromDate
Dim toDate
Dim days
Dim daysNode
set daysNode = XDocument.DOM.selectSingleNode("/my:myFields/my:DaysRemaining")
fromDate = Trim(XDocument.DOM.selectSingleNode("/my:myFields/my:FromDate").text)
toDate = Trim(XDocument.DOM.selectSingleNode("/my:myFields/my:ToDate").text)
if Len(fromDate) = 0 Or Len(toDate) = 0 Then
daysNode.text = "n/a"
else
fromDate = CDate(fromDate)
toDate = CDate(toDate)
days = DateDiff("d", fromDate, toDate)
' Determine whether the xsi:nil attribute is set for this
' element. If so, remove the xsi:nil attributes so that
' the value can be set.
if Not IsNull(daysNode.getAttribute("xsi:nil")) then
daysNode.removeAttribute("xsi:nil")
end if
daysNode.text = CStr(days)
end if
End Sub
Stephanie Cantwell / Test ManagerQdabra® Software / Streamline data gathering to turn process into knowledge