Convert DateTime to Date string “dd/mm/yyyy”

You may leave the List creation as is, with no conversion to the required format. So you may use you code as:

_unitOfWork.PlacementFinancialViewRepository.GetEfs07Placements().Where(x => x.FiscalYear == fiscalYear && x.ResponsibleSauId == responsibleDistrictId)
.ToList()
.Select(x => new Efs07PlacementModel
{
    PlacementStartDate = x.PlacementStartDate == null ? null : x.PlacementStartDate,
    PlacementEndDate = x.PlacementEndDate == null ? null : x.PlacementEndDate
}).ToList();

Then you can then convert the PlacementStartDate to your required format at the time yo uare displaying it on a View/UI.

Leave a Comment