LINQ convert datetime to shortdate and order accending

Peter Newman 66 Reputation points
2021-11-23T13:35:21.39+00:00

I am trying to add a list of dates to a viewbag

despite several attempts I'm still not getting anywhere

currently the list that produced from my query is

26/11/2021 00:00:00
25/11/2021 00:00:00
24/12/2021 00:00:00
29/11/2021 00:00:00

I'm trying to get to

24/11/2021
25/11/2021
29/11/2021
24/12/2021

my query

ViewBag.closeddateslist = (From d In db.new_closeddates Order By d.new_date Ascending Select d.new_date).ToList()

Class

Public Property new_date As Nullable(Of Date)

The public property cannot be changed

Developer technologies | ASP.NET | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.