Wednesday, July 21, 2010

Compare date with current date using c#

Here I have publish how to compare text box date with current date using c#

DateTime dat1 = DateTime.Parse(txtFromDate.Text);

DateTime dat2 = DateTime.Parse(DateTime.Now.ToShortDateString());

if (DateTime.Compare(dat1, dat2) > 0)
{
lbl.Text = "Date must be less than current date.";

}

First Date I have got from my application, Second date is system date , using
c# compare method , I have compared both date.

No comments:

Post a Comment