I am using LINQ to get my correct data,inside this LINQ am calling one method to check the date difference.If the date difference goes negative LINQ returns me anonymous type.How I can handle this and how I will get this negative number as I aslo need this to my further use.
var daysCount = (from projCount in dtExpiring.AsEnumerable()
where projCount.Field<int>("AccountId") == accId
&& (checkDate(projCount.Field<DateTime>("ValidFor"))) <= 5
&& (checkDate(projCount.Field<DateTime>("ValidFor"))) >= 0
select new { daysRemain = (checkDate(projCount.Field<DateTime>("ValidFor"))) }).Distinct();
private int checkDate(DateTime validFor)
{
try
{
DateTime date = DateTime.Now;
int diffDays = Convert.ToInt32(Math.Round((validFor - date).TotalDays));
return diffDays;
}
catch (Exception)
{
return 0;
}
}