Below is smaple code from my form
{
1: XPathNavigator docFM = this.CreateNavi gator();
2: string date_form = docFM.SelectSin gleNode("/my:myFields/my:startDate",
this.NamespaceM anager).Value;
3: XPathNavigator docFN = this.CreateNavi gator();
4: string date_to = docFN.SelectSin gleNode("/my:myFields/my:startTime",
this.NamespaceM anager).Value;
5: DateTime startDate = Convert.ToDateT ime(date_frorm) ;
6: DateTime endDate = Convert.ToDateT ime(date_to);
7: TimeSpan dateDifference = endDate.Subtrac t(startDate);
8: int days = dateDifference. Days;
9: string daysString = days.ToString() ;
10: XPathNavigator dateDiffTextBox Value =
this.CreateNavi gator().SelectS ingleNode("/my:myFields/my:dateDiff",
this.NamespaceM anager);
11: dateDiffTextBox Value.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.s pamwrote in message
news:ei******** ******@TK2MSFTN GP06.phx.gbl...
"andyoye" <an*****@nospam .comwrote in message
news:ek******** ******@TK2MSFTN GP06.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.