Formatting date in Linq-to-Entities query causes exception

后端 未结 4 1582
遇见更好的自我
遇见更好的自我 2020-12-03 17:57

I have Entity class with datetime filed, I want to select distinct \'mon-yyyy\' format datetime filed value and populate drop down list.

the following code giving me

4条回答
  •  遥遥无期
    2020-12-03 18:22

    I used a workaround to build the formats containing yyyy and MM manually. I would like to mention it here if it may help someone (at least temporarily):

    FormattedDate = d.ReportDate.Year.ToString() + "-" + d.ReportDate.Month.ToString()
    

    this makes the format yyyy-MM

提交回复
热议问题