dimanche 16 octobre 2016

How to take year 2016 onwards?

I have this code below working fine w/o the condition in the line payrollEndDate = p.PayrollEndDate.Value.Year >= 2016 because it gives me an error Invalid cast from 'Boolean' to 'DateTime'. and the code that I added is return a boolean

var per = (from p in db.Periods select new { periodId = p.PeriodId, periodStart = p.StartDate, periodEnd = p.EndDate, payrollEndDate = p.PayrollEndDate.Value.Year >= 2016 });
var periods = (from p in per.AsEnumerable() select new { perId = p.periodId, PayrollEndDate = Convert.ToDateTime(p.payrollEndDate).ToShortDateString() }).AsQueryable();
ViewBag.PeriodEndDate = new SelectList(periods, "PayrollEndDate", "PayrollEndDate", null);

How to take the year 2016 onwards?

Aucun commentaire:

Enregistrer un commentaire