two calenders
one button
One text box
I need to get the difference of two selected dates in day wise(i.e.. 1 day, or 2 days, or 3 days)
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 11, 2014, 6:46 AM EDT
protected button1_Click(object sender, EventArgs e)
{
DateTime dt1 = calendar1.SelectedDate.Date;
DateTime dt2 = calendar2.SelectedDate.Date;
int days = (int)Math.Abs((dt1 - dt2).TotalDays);
textBox1.Text = days.ToString();
}