How to subtract two dates values store in third text box
subtract two dates values store in third text box
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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 Jun 20, 2014, 8:27 AM EDT
DateTime dt1 = DateTime.Parse(textBox1.Text);
DateTime dt2 = DateTime.Parse(textBox2.Text);
TimeSpan ts = (dt2 - dt1).Duration();
textBox3.Text = ts.ToString();
Abhay ShankerRank #375 · 6.7K reputationPosted Jun 20, 2014, 9:14 AM EDT
DateTime firstDate= DateTime.Parse(textBox1.Text);
DateTime secondDate = DateTime.Parse(textBox2.Text);
string daydiff = (secondDate - firstDate).TotalDays.ToString();
textBox3.Text =daydiff2;