I have a ViewBag returning two dates in a DropDown, but they are returning with the same formatting that was saved in the database (MM / dd / yyy HH: mm: ss). I need them to return in the pattern (dd / MM / yyyy).
My ViewBag looks like this:
ViewBag.Ferias = funcionarioFeriasRepository.Lista.Where(r => r.CdMatricula == matricula && r.SqContrato == contrato && r.DtInicioConcessao != null)
.Select(x => x.DtInicioPeriodo + " à " + x.DtFimPeriodo);
And in my view, I call it this way:
@Html.DropDownList("Ferias", new SelectList(ViewBag.Ferias, "Ferias"))
The result is this:
Jun 22 2010 12:00 AM to Feb 19 2014 12:00 AM