Click here to Skip to main content
15,894,252 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
How to create End Date should be greater than Start Date in asp.net? Plz give any idea.
Posted
Comments
JoCodes 14-Sep-13 4:34am    
Are you looking for validations for the Start and end dates?

string endDate="1/6/2013";
string start ="1/1/2013"

if (Convert.ToDateTime(start).CompareTo(Convert.ToDateTime(endDate)) < 0)
{
//your block of code;
}
 
Share this answer
 
Already there are lots of date validation related articles available

Check this
[^]
 
Share this answer
 
On server side you can compare the two values as the follows:
DateTime d1 = DateTime.Now;
DateTime d2 = yourObject.value;

if (d2 > d1)
{
    //your code
}


You can use clientside validation also.
 
Share this answer
 
Hi Manvendra patel, here is the link to your solution which helps you.
http://msdn.microsoft.com/en-us/library/system.datetime.compare.aspx[^]

Please post if you want any more help.

Thanks
Ganesh
 
Share this answer
 
C#
function checkDate()
{
var  fromDate=document.getElementById("<%=tcstartdate.ClientID%>").value.trim();
   var toDate=document.getElementById("<%=tcenddate.ClientID%>").value;
 var record_day1=fromDate.split("/");
var record_day2=toDate.split("/");
 if(record2 < record1)
    {
            alert("End date should be greater than start date");
            return false;
    } 
} 


put it in a javascript function call it on click of button :)
 
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