Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I have two textBoxes ( to display dates) in my application. i'm using calender control (javascript) to select dates, and the selected date populated in to textBox.

here my probelm is:

i'm unbale to display the difference between these dates (selected using calender control) in the third textbox.

can anyone Please help me.

Thanks in adv.
Ramesh
Posted

Use following code :
C#
private void Calendar1_SelectionChanged (object sender,
   System.EventArgs e)
{
   SelectedDatesCollection theDates = Calendar1.SelectedDates;
   TimeSpan timeSpan = theDates[theDates.Count-1] - theDates[0];
   TextBox1.Text = String.Format("You have selected {0} day(s).", timeSpan.Days + 1);
}   
 
Share this answer
 
Use the TimeSpan class to get the difference. http://msdn.microsoft.com/en-us/library/1b6ff9et%28v=vs.71%29.aspx[^] is a good example that should help you out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900