Linq to sql orderby date?

Skip the ToString("yyyy-MM-dd") var q = from na in db. NewsArticles orderby Convert. ToDateTime(na.

ArticleCreated) descending select na EDIT Since the DB collation does not seem to mach your date formatting, you can try this: var q = db.NewsArticles.AsEnumerable(). OrderByDescending(x => DateTime. Parse(x, new CultureInfo("en-GB", false).

DateTimeFormat)) Where "en-GB" is the culture from which your formatting is used. (you might need to change that).

Skip the . ToString("yyyy-MM-dd") var q = from na in db. NewsArticles orderby Convert.

ToDateTime(na. ArticleCreated) descending select na; EDIT Since the DB collation does not seem to mach your date formatting, you can try this: var q = db.NewsArticles.AsEnumerable(). OrderByDescending(x => DateTime.

Parse(x, new CultureInfo("en-GB", false). DateTimeFormat)) Where "en-GB" is the culture from which your formatting is used. (you might need to change that).

This throws; The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. – Dooie Jul 10 at 18:13 I cannot change the column type without losing data, but what collation should I use? – Dooie Jul 10 at 18:35 The best solution is the change the column to a DateTime.

Or you can try to do the sorting out of the database, see my edit. – Magnus Jul 10 at 18:35 Thx that worked using your edit. I will look into converting the column on the db for a permanent solution.

– Dooie Jul 10 at 18:45.

NewsArticles orderby (Convert. String)' has no supported translation to SQL.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions