две даты проверки
привет как проверить две даты как первая дата меньше чем вторая дата
спасибо
[no name]
Вопрос должен быть ясен!
Сравнение в SQL или ASP.Net-что?
Вопрос должен быть ясен!
Сравнение в SQL или ASP.Net-что?
Declare @D1 datetime, @D2 datetime set @D1 = '2013-07-05' --yyyy-mm-dd set @D2 = '2013-07-09' --yyyy-mm-dd select case when @D1 = @D2 then 'equal dates' when @D1 < @D2 then 'first date is less then second date' else 'Second date is less then first date' end
Обратитесь к этому. Это слишком просто.
значение datetime.Метод Сравнения[^]
С уважением.. :смеяться:
Привет,
попробовать это
declare @D1 date declare @D2 date set @D1='15-june-2013' set @D2 ='15-apr-2013' if DATEDIFF(day,@D1,@D2) > 0 ( select 'first date is lesser then second' ) else if DATEDIFF(day,@D1,@D2) < 0 ( select 'second date is lesser then first' ) else if DATEDIFF(day,@D1,@D2) = 0 ( select 'Both date are same' )
function checkDate() { var fromDate=document.getElementById("<%=tcstartdate.ClientID%>").value; var toDate=document.getElementById("<%=tcenddate.ClientID%>").value; var cataloguename=document.getElementById("<%=txtcataloguename.ClientID%>").value; var desc=document.getElementById("<%=txtdescription.ClientID%>").value; if(cataloguename.trim() == "") { alert("Please Enter Special name"); document.getElementById("<%=txtcataloguename.ClientID%>").focus(); return false; } if(fromDate == "") { alert("Please Enter Special start date"); document.getElementById("<%=tcstartdate.ClientID%>").focus(); return false; } if(toDate == "") { alert("Please Select Special End date"); document.getElementById("<%=tcenddate.ClientID%>").focus(); return false; } // alert(fromDate); // alert(toDate); var record_day1=fromDate.split("/"); var sum1=record_day1[1]+'/'+record_day1[0]+'/'+record_day1[2]; var record_day2=toDate.split("/"); var sum2=record_day2[1]+'/'+record_day2[0]+'/'+record_day2[2]; var record1 = new Date(sum1); var record2 = new Date(sum2); var d = new Date(); var ddd =d.getMonth()+ 1 +'/'+d.getDate()+'/'+d.getFullYear(); var dd=new Date(ddd); if(record2 < record1) { alert("Invalid Date ! Please try again"); document.getElementById("<%=tcstartdate.ClientID%>").focus(); return false; } if(record2 < dd) { alert("Invalid Date ! Please try again"); document.getElementById("<%=tcstartdate.ClientID%>").focus(); return false; } // if(desc.trim() == "") // { // alert("Please enter description "); // document.getElementById("<%=txtdescription.ClientID%>").focus(); // return false; // } var inputs = []; var i,c=0; grid=document.getElementById("<%=gridCatalogue.ClientID %>"); inputs = document.getElementById("<%=gridCatalogue.ClientID %>").getElementsByTagName("input"); var input=document.getElementsByTagName("input"); for (i=0;i<grid.rows.length-1;i++) if(inputs[4*i].value!="") { c++; } if(c==0) { alert("Please enter atleast one product"); return false; } //alert('came'); var input=document.getElementsByTagName("input"); var sample,hidid; for(var i=0;i<input.length;i++) { //alert(input[i].type); if(input[i].type=="hidden") hidid=document.getElementById(input[i].id).value; if(input[i].type=="text") { if(input[i].id.indexof("txtprice")>0) { sample=document.getElementById(input[i].id).value; if(isnan(parseint(sample)) && !isnan(parseint(hidid))) { alert("Please enter price"); document.getElementById(input[i].id).focus(); return false; } else if(!isnan(parseint(hidid))) { var isfound = /^(?!^0*$)(?!^0*\.0*$)^\d{1,10}(\.\d{1,2})?$/.test(sample); if(isfound) { } else { alert('Invalid price ! please try again'); document.getElementById(input[i].id).value=""; document.getElementById(input[i].id).focus(); return false; } } } } } }
try this javascript,... <script type="text/javascript" language="javascript"> function ValidateSearch() { var msg = document.getElementById('<%=lblListMsg.ClientID%>'); var FromDate = document.getElementById('<%=txtFromDate.ClientID%>').value; var ToDate = document.getElementById('<%=txtToDate.ClientID%>').value; var startDate = new Date(getJSDate(FromDate)); var endDate = new Date(getJSDate(ToDate)); var curDate = new Date(); if (startDate > curDate) { msg.innerHTML = "From date should not be greater than today's date"; msg.style.color = "red"; document.getElementById('<%=txtFromDate.ClientID%>').value = ""; document.getElementById('<%=txtFromDate.ClientID%>').focus(); return false; } if (endDate > curDate) { msg.innerHTML = "To date should not be greater than today's date"; msg.style.color = "red"; document.getElementById('<%=txtToDate.ClientID%>').value = ""; document.getElementById('<%=txtToDate.ClientID%>').focus(); return false; } if (startDate > endDate) { msg.innerHTML = "From date should not be greater than to date"; msg.style.color = "red"; document.getElementById('<%=txtFromDate.ClientID%>').value = ""; document.getElementById('<%=txtFromDate.ClientID%>').focus(); return false; } document.getElementById('<%=lblListMsg.ClientID%>').innerHTML = ""; return true; } </script> to call javascript method <asp:Button ID="btnSearchPO" runat="server" OnClientClick="return ValidateSearch()" /> Accept as answer if solve you problem.
Привет...
Я беру два текстовых поля, таких как: TextBox1 и TextBox2.
Теперь я сравниваю два значения текстового поля, таких как blo.
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1" ControlToValidate="TextBox2" ErrorMessage="date2 must greater than date1" Operator="GreaterThan" Type="Date" CultureInvariantValues="True"></asp:CompareValidator>