敏时间和最大日期 [英] Min Date and Max date

查看:168
本文介绍了敏时间和最大日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有日期的列表如下

I have a list of dates as below

 List<string> nameList = new List<string>();
 nameList.Add("20120618PM");
 nameList.Add("20120622PM");
 nameList.Add("20120622AM");
 nameList.Add("20120628PM");
 nameList.Add("20120702PM");
 nameList.Add("20120629AM");
 nameList.Add("20120629PM");



我想从列表中查找MAXDATE和MIN日期。请让我知道我可以继续进行。

I want to find MAXDATE and MIN DATE from the list .Please let me know how can i proceed.

问候,

Regards,
Channa

推荐答案

如果日期格式为YYYYMMDD则是作为排序即使有AM / PM

If the date format is yyyyMMdd then is is sortable as strings even with AM/PM

 nameList.Max()

如果您有一年多小时/分钟和AM / PM,那么你必须分析为DateTime。我建议无论解析,在其他的答案建议。

If you have a year plus hours/minutes and AM/PM then you must parse to DateTime. I recommend parsing regardless, as suggested in other answers.

这篇关于敏时间和最大日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆