Below is smaple code from my form
{
1: XPathNavigator docFM = this.CreateNavigator();
2: string date_form = docFM.SelectSingleNode("/my:myFields/my:startDate",
this.NamespaceManager).Value;
3: XPathNavigator docFN = this.CreateNavigator();
4: string date_to = docFN.SelectSingleNode("/my:myFields/my:startTime",
this.NamespaceManager).Value;
5: DateTime startDate = Convert.ToDateTime(date_frorm);
6: DateTime endDate = Convert.ToDateTime(date_to);
7: TimeSpan dateDifference = endDate.Subtract(startDate);
8: int days = dateDifference.Days;
9: string daysString = days.ToString();
10: XPathNavigator dateDiffTextBoxValue =
this.CreateNavigator().SelectSingleNode("/my:myFields/my:dateDiff",
this.NamespaceManager);
11: dateDiffTextBoxValue.SetValue(daysString);
}
I get
"String was not recognized as a valid DateTime." at line 6
"When convertin a string to DateTime, parse the string to take the date
before putting each variable into the DateTime object"
thx
"Jeff Johnson" <i.***@enough.spamwrote in message
news:ei**************@TK2MSFTNGP06.phx.gbl...
"andyoye" <an*****@nospam.comwrote in message
news:ek**************@TK2MSFTNGP06.phx.gbl...
>startDate field value is 10-01-09
endDate field value is 10-05-09
How can I get 4 .....(endDate-startDate)
Alberto gave you the answer.