Steve Lam
Steve Lam

Reputation: 1049

OrderBy list for only Date but not Time

I have IList<customClass>

My CustomClass: CreatedDate(DateTime), Name(string), Number(int)

I use OrderBy(p => p.CreatedDate)

My question: how do I custom or find a way to order CreatedDate just only Date, not include Time when order?

Upvotes: 2

Views: 818

Answers (1)

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73442

Given that CreatedDate is of type DateTime you can do the following.

OrderBy(p => p.CreatedDate.Date)

Upvotes: 8

Related Questions