comparing dates asp.net
-
Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...
-
Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...
Hi there. Just a suggestion - it looks like you're building client javascript code for the purpose of validation... if this is for an ASP.NET application, you may want to use a CompareValidator[^] control instead. The validator controls include a property
EnableClientScript
that governs whether or not they will output client-side javascript for validation. -
Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...
Hello, I think you should convert the days, months and years to a number like this: strStartDay = Number (frm.txtStartDay.value); The comparision should now work! Greetings from Stephan
-
Hi all, this is my function which will compare the two dates start & end.....i no that this code was not sufficient to compare bocz...whenever the dates are like start-- 23-6-2004 & end--- 7-6-2004 it compares only the 2 in 23 with 7 & dont gives any message...so plz help me... function compareDate() { var strStartDay; var strStartMonth; var strStartYear; var strEndDay; var strEndMonth; var strEndYear; strStartDay =frm.txtStartDay.value; strStartMonth =frm.txtStartMonth.value; strStartYear =frm.txtStartYear.value; strEndDay =frm.txtEndDay.value; strEndMonth =frm.txtEndMonth.value; strEndYear =frm.txtEndYear.value; if(strStartDay > strEndDay || strStartMonth > strEndMonth || strStartYear > strEndYear ) { alert("End Date should be Greater" + strEndDay + strEndMonth + strEndYear); } Thanks...
you can use DateDiff Function in .NET assume we want to find the difference between two days Dim dattim1 As Date = #5/17/2004# Dim dattim2 As Date = #5/31/2004# Dim WD As Long = DateDiff(DateInterval.Day, dattim1, dattim2) WD Returned the numbers of diff. days between dattim1 and dattim2 and you can user validator controls to specify the format of date and others I.N.M(InterNetMouse)