Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hi to all,


currently i am doing project in tender mgmt.
if i want to insert the tender details,i want tender announced date and due date. i entered the tender announced date as 5/12/2010 and due date as 5/6/2009. it is not acceptable,bcoz due date must be above the announced date, i want to do date comparison .pls tell me
Posted

You can always use DateDiff to do a date comparision.[^]
 
Share this answer
 
Use JavaScript[^] before inserting into database or

Use Compare validator[^].
 
Share this answer
 
v2
Use Compare Validator if you are using asp.net

XML
<asp:CompareValidator ID="cmvdate" Display="Dynamic" ErrorMessage="InvalidDate" SetFocusOnError="true"
                                        runat="server" ControlToCompare="txt_DateFrom" ControlToValidate="txt_DateTo"
                                        Operator="GreaterThanEqual">*</asp:CompareValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="txt_DateTo"
                                        SetFocusOnError="true" Display="Dynamic" ValidationExpression="(([1-9]|1[012])[- /.]([1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d)|((1[012]|0[1-9])(3[01]|2\d|1\d|0[1-9])(19|20)\d\d)|((1[012]|0[1-9])[- /.](3[01]|2\d|1\d|0[1-9])[- /.](19|20)\d\d)"   ErrorMessage="Date" runat="server">*


if You want that in Sql Server
Check
declare @StartDate datetime, @EndDate datetime

if(@StartDate<@EndDate datetime)
begin
Your Code
end
else
Your Code
begin
end
 
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