Suppose we have two TextBox Which Id's are txtStartDate and txtEndDate
string frmdt = txtStartDate.Text;
string todt = txtEndDate.Text;
FromDate=string.empty;
ToDate =string.empty;
int Datediff = 0;
int diff = 0;
//For this use the namespace System.Globalization;
FromDate = Convert.ToDateTime(frmdt, c).ToString("dd-MMM-yyyy", DateTimeFormatInfo.InvariantInfo);
ToDate = Convert.ToDateTime(todt, c).ToString("dd-MMM-yyyy", DateTimeFormatInfo.InvariantInfo);
//your answer in start here
//Code for date difference
DateTime dt2 = Convert.ToDateTime(ToDate);
DateTime dt1 = Convert.ToDateTime(FromDate);
Datediff = DateTime.Compare(dt1, dt2);
TimeSpan diff1 = dt2.Subtract(dt1);
diff = Convert.ToInt32(diff1.Days);
if(diff<=100)
respsoe.write("hellow");
Chandresh
Vijayar, if this helps please login to Mark As Answer. | Alert Moderator