Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max DateTime in a list

Tags:

c#

c#-2.0

How do you get the max datetime from a list of DateTime values using C# 2.0?

like image 451
Greens Avatar asked Sep 17 '09 16:09

Greens


People also ask

How to get max date in list of dates python?

To get the maximum datetime in Python, you can use the max() function. This function returns the maximum value of all the datetime objects in a list. You can also use this function to find the maximum datetime in a dictionary.

What is the maximum date in python?

Python datetime class Notice that, we assigned and used the alias name to this class as gm. The MAXYEAR returns the maximum(highest) year supported by the module, i.e., 9999.

What is datetime max value?

Remarks. The value of this constant is equivalent to 23:59:59.9999999 UTC, December 31, 9999 in the Gregorian calendar, exactly one 100-nanosecond tick before 00:00:00 UTC, January 1, 10000.

What is the max datetime in C#?

The default and the lowest value of a DateTime object is January 1, 0001 00:00:00 (midnight). The maximum value can be December 31, 9999 11:59:59 P.M. Use different constructors of the DateTime struct to assign an initial value to a DateTime object.


1 Answers

What's with all the iterating....this is very trivial

// Given...
List<DateTime> dates = { a list of some dates... }

// This is the max...
DateTime MaxDate = dates.Max();
like image 62
user170486 Avatar answered Oct 04 '22 09:10

user170486