private double DateDiff(string howtocompare, System.DateTime startDate, System.DateTime endDate)
{
double diff=0;
System.TimeSpan TS = new System.TimeSpan(endDate.Ticks-startDate.Ticks);
switch (howtocompare.ToLower())
{
case "year":
diff = Convert.ToDouble(TS.TotalDays/365);
break;
case "month":
diff = Convert.ToDouble((TS.TotalDays/365)*12);
break;
case "day":
diff = Convert.ToDouble(TS.TotalDays);
break;
case "hour":
diff = Convert.ToDouble(TS.TotalHours);
break;
case "minute":
diff = Convert.ToDouble(TS.TotalMinutes);
break;
case "second":
diff = Convert.ToDouble(TS.TotalSeconds);
break;
}
return diff;
}