Aniket Narvankar

Aniket Narvankar

  • 567
  • 2.1k
  • 604k

Order data in descending order using AM/PM format in c sharp

Apr 14 2023 6:14 AM

outputData = output.OrderByDescending(x => DateTime.ParseExact(x.modifiedDateTime, "MM/dd/yyyy hh:mm:ss", CultureInfo.InvariantCulture)).ToList();

in the above code x.modifiedDateTime stores date in MM/dd/yyyy hh:mm:ss format and we are ordering using MM/dd/yyyy hh:mm:ss format. But now i want to order using MM/dd/yyyy hh:mm:ss tt(AM/PM) format, how could this be done. also modifiedDateTime should be displayed  MM/dd/yyyy hh:mm:ss format

How could this be done. please help on this.


Answers (2)