My apologies Ms. Wong-A-Ton, I hope I have not offended you. Thank you very
much for the reply. I have scavanged through all of the code examples I can
find and the documentation you sent me, however, I am still at a loss for
figuring out something that is probably very simple. Some of the code
examples appear to have arguments that are not compatible with InfoPath 2003
and I do not know what the arguments should be. Specifically, I do think the
'DateTime' object is valid, nor the 'TimeSpan' object.
My code so far:
function msoxd_my_IFSPDate::OnAfterChange(eventObj)
{
if (eventObj.IsUndoRedo)
return;
var date1Node = XDocument.DOM.selectSingleNode( "/my:IFSP/my:IFSPDate" );
var date2Node = XDocument.DOM.selectSingleNode(
"/my:IFSP/my:ReferralDate" );
var diffNode = XDocument.DOM.selectSingleNode( "/my:IFSP/my
ifference"
);
if( date1Node != null && date2Node != null && diffNode != null )
{
try
{
DateTime dt1 = GetDate( date1Node.text );
DateTime dt2 = GetDate( date2Node.text );
TimeSpan ts = dt2 - dt1;
diffNode.txt = ts.Days.ToString();
}
catch( FormatException ) {}
}
}
I am using the following function to put the date in ISO8601 format and it
is working for my other functions.
function GetDateString(dateObj)
{
var yyyy = dateObj.getFullYear();
var mm = dateObj.getMonth() + 1;
var dd = dateObj.getDate();
if (mm < 10)
mm = "0" + mm;
if (dd < 10)
dd = "0" + dd;
return yyyy + "-" + mm + "-" + dd;
}
I am not sure what I am doing wrong, since before this week, I have never
worked with this level of programming before
Thank you for everything you
do for all of us lost in code!