Comparing Two Dates...


 

DateTime dd1 = Convert.ToDateTime(textBox1.Text);
DateTime
dd2 = Convert.ToDateTime(textBox2.Text);
if (dd1.CompareTo(dd2) == 1)
{
            //Textbox1 Date Is Greater Than Textbox2 Date...
            MessageBox.Show(dd1.Date.ToShortDateString() + " Is Greater Than " + dd2.Date.ToShortDateString());
}
else if (dd1.CompareTo(dd2) == -1)
{
            //Textbox2 Date Is Greater Than Textbox1 Date...
            MessageBox.Show(dd2.Date.ToShortDateString() + " Is Greater Than " + dd1.Date.ToShortDateString());
}
else
{
            MessageBox.Show("Both Dates Are Equal.");
}


Ebook Download
View all
Learn
View all