How do you get the max datetime from a list of DateTime values using C# 2.0?
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.
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.
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.
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.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With