Click here to Skip to main content
15,867,985 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to cpmpare two dates date current date and maximum date ........plzz help me
Posted
Comments
Mandy Nagra 5-Nov-12 3:12am    
plzz anyboday help me

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, ...).
 
Share this answer
 
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
 
Share this answer
 
Comments
Daniele Rota Nodari 12-Nov-12 6:09am    
Compare dates converted to string format is culture dependent, and thus is likely to not work in many cultures
Means what , input should not be greater than current date? or compare two dates value?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900