如何cpmpare两个日期日期当前日期和最大日期........ plzz帮帮我

问题描述:

如何cpmpare两个日期,当前日期和最大日期........ plzz帮助我

how to cpmpare two dates date current date and maximum date ........plzz help me

查看 DateTime.Subtract方法,以获取两个源日期之间的时间跨度,以便您可以单独分析每个日期/时间组件(年,日,分钟,...).
Look at DateTime.Compare Method for straight compare method, or
DateTime.Subtract Method to get a time-span between the two source dates, so that you can analyze every date/time component by itself (year, day, minute, ...).


DateTime srtdate = Convert.ToDateTime(allitem ["StartDate"].Text.ToString() );
DateTime srtdate = Convert.ToDateTime(allitem ["StartDate"].Text.ToString());

(DateTime.Now.ToShortDateString()> = srtdate.ToShortDateString())

开始日期-2012年2月22日和结束日期-2012年2月22日
if(((DateTime.Today> = strdate.Date)&&(DateTime.Today< = enddate.Date))
lblCondition.Text =已检查";

这样,您就可以比较两个日期
DateTime srtdate = Convert.ToDateTime(allitem["StartDate"].Text.ToString());
DateTime srtdate = Convert.ToDateTime(allitem["StartDate"].Text.ToString());

(DateTime.Now.ToShortDateString() >= srtdate.ToShortDateString())

Start Date - 22-Feb-2012 AND End Date - 22-Feb-2012
if ((DateTime.Today >= strdate.Date) && (DateTime.Today <= enddate.Date))
lblCondition.Text = "CHECKED";

this Way u Can compare two dates


意味着什么,输入内容不应大于当前日期?或比较两个日期值?
Means what , input should not be greater than current date? or compare two dates value?