本文介绍了验证两个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
如何验证第一个日期之类的两个日期少于第二个日期
感谢
hihow to validate two date like first date is less then second date
thanks
推荐答案
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
快乐编码!
:)
Happy Coding!
:)
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*
这篇关于验证两个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!