0

I need to check a difference between a given date and current date is less than 365days?

i tried some thing like this.

System.TimeSpan diff = DateTime.UtcNow.Subtract((DateTime)customer.LastValidationDate);
 result = (diff.Days < 1);

this doesn't seem to work correct for few dates.

i need to achieve: if given date and current date difference is less-than or equal to 1 year (365 days) return true else return false.

HaBo
  • 13,999
  • 36
  • 114
  • 206

1 Answers1

0

try this found at stackoverflow

    public static int MonthDifference(this DateTime lValue, DateTime rValue)
{
    return (lValue.Month - rValue.Month) + 12 * (lValue.Year - rValue.Year);
}
Community
  • 1
  • 1