I'm trying to get the difference between two dates, but I get this error:
Cannot Convert type 'int?' to 'System.TimeSpan'
Then I tried to use Convert.ToInt32()
or Int32.Parse()
, but still had the same error.
Can anyone please help me or point me in the right direction?
ViewModel:
public class RMACLOSE
{
public TimeSpan? diff { get; set; }
}
Controller:
var list = from RH in RMA_History
select new RMACLOSE
{
// Cannot Convert type 'int?' to 'System.TimeSpan?'
diff = DbFunctions.DiffDays(RH.EndDate, RH.StartDate)
}
RH.EndDate
(DateTime
): 2018-11-15 12:15:00.000
RH.StartDate
(DateTime
): 2018-05-24 15:43:00.000
Difference : 175 days