简体   繁体   中英

Find Maximum time value from list of time value

I need to find the maximum time value from the list:

num[2] = 2012-12-16 16:56:31

I have tried with following:

max =0
for num in list:
 if num[2] > max:
   max = num
print max

But it is showing error:

    if num[5] > max:
TypeError: can't compare datetime.datetime to int

You can do

max(my_dates)

Don't call your list, list, as that shadows a builtin and makes confusing errors later on.

Don't name your variables anything in this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM