How can i use a orderby clause using a DateTime field ignoring the year?
Is that possible?
2 Answers, 1 is accepted
answered on 16 Nov 2012, 04:40 PM
In order to use the OrderBy clause on a DateTime field ignoring the year I suggest you to base your query on the following code snippet which is retrieving data from the Orders table of the Northwind database.
using (YourContextName db = new YourContextName())
var orderByDateTimeWithoutYear = db.Orders
.Where(x => x.OrderDate.HasValue)
.OrderBy(x => x.OrderDate.Value.Month)
.ThenBy(x => x.OrderDate.Value.Day);
If you want to become more familiar with the LINQ capabilities of OpenAccess ORM you can download our SDK and look at our Linq 101 sample.
I hope this helps.
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.