I am using MVC3 webgrid. I am displaying the data in a webgrid and before displaying the data I have to calculate the number of days between start date and end date. I am using the following code.
int noOfAbsenceDays = item.AbsEnd?(item.AbsEnd.Subtract(item.AbsStart)).Days: (item.DateTime.Now.Subtract(item.AbsStart)).Days;
It complains about this error
Cannot implicitly convert type 'System.DateTime' to 'bool'
I don’t know where it is coming from?
Thanks
You can try the following code:
int noOfAbsenceDays = item.AbsEnd == null ? (item.AbsEnd.Subtract(item.AbsStart)).Days : (item.DateTime.Now.Subtract(item.AbsStart)).Days;