shaikhidayat
asked on
problem with dates
hello experts,
i put textbox and change the field properties as datetime.when i run this in notes client its working fine.the same when i run this on web calender type is not coming.i dont want to user should select the dates from the control not by typying manually. and one more thing is i want to calculate difference in dates.if it is greater than 21 days it should give message that diff should be less than 21 days.how to do this.is there any inbuilt control is there.
waiting for answer.
i put textbox and change the field properties as datetime.when i run this in notes client its working fine.the same when i run this on web calender type is not coming.i dont want to user should select the dates from the control not by typying manually. and one more thing is i want to calculate difference in dates.if it is greater than 21 days it should give message that diff should be less than 21 days.how to do this.is there any inbuilt control is there.
waiting for answer.
Here are links to examples of datepickers
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/66e4875af353f8e2852569ba00515bbe?OpenDocument&Highlight=0,datepicker
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/c1a3c1f8e69eddbd85256996006e5bd0?OpenDocument&Highlight=0,datepicker
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/324d71c3674d08fc8525694d004c27f5?OpenDocument&Highlight=0,datepicker
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/66e4875af353f8e2852569ba00515bbe?OpenDocument&Highlight=0,datepicker
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/c1a3c1f8e69eddbd85256996006e5bd0?OpenDocument&Highlight=0,datepicker
http://www.notes.net/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/324d71c3674d08fc8525694d004c27f5?OpenDocument&Highlight=0,datepicker
This is the formula for calculating the days
<body>
<form name=exf1>
D1 <input name=d1 type=text value="01">
M1 <input name=m1 type=text value="01">
Y1 <input name=y1 type=text value="2000">
<BR>
D2 <input name=d2 type=text value="03">
M2 <input name=m2 type=text value="05">
Y2 <input name=y2 type=text value="2000">
<BR>
Delta Days <input type=text name=delta value="<?>">
<BR>
Business Days <input type=text name=bizdelta value="<?>">
<BR>
<input type=button onclick="compute()" value="compute!">
</form>
<script type=text/javascript>
function compute() {
var date1 = new Date();
date1.setYear (document.exf1.y1.value);
date1.setMonth (document.exf1.m1.value);
date1.setDate (document.exf1.d1.value);
var date2 = new Date();
date2.setYear (document.exf1.y2.value);
date2.setMonth (document.exf1.m2.value);
date2.setDate (document.exf1.d2.value);
var delta = date1.getTime() - date2.getTime();
delta = delta / ( 1000 * 60 * 60 * 24 ); // units are now days.
if (delta < 0) delta = -delta;
delta = Math.round(delta);
document.exf1.delta.value = delta;
if (delta > 21) alert("Data difference should be less then 21 days")
}
</script>
<body>
<form name=exf1>
D1 <input name=d1 type=text value="01">
M1 <input name=m1 type=text value="01">
Y1 <input name=y1 type=text value="2000">
<BR>
D2 <input name=d2 type=text value="03">
M2 <input name=m2 type=text value="05">
Y2 <input name=y2 type=text value="2000">
<BR>
Delta Days <input type=text name=delta value="<?>">
<BR>
Business Days <input type=text name=bizdelta value="<?>">
<BR>
<input type=button onclick="compute()" value="compute!">
</form>
<script type=text/javascript>
function compute() {
var date1 = new Date();
date1.setYear (document.exf1.y1.value);
date1.setMonth (document.exf1.m1.value);
date1.setDate (document.exf1.d1.value);
var date2 = new Date();
date2.setYear (document.exf1.y2.value);
date2.setMonth (document.exf1.m2.value);
date2.setDate (document.exf1.d2.value);
var delta = date1.getTime() - date2.getTime();
delta = delta / ( 1000 * 60 * 60 * 24 ); // units are now days.
if (delta < 0) delta = -delta;
delta = Math.round(delta);
document.exf1.delta.value = delta;
if (delta > 21) alert("Data difference should be less then 21 days")
}
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hai sloeber,
thanks for sending me very fast reply.one of solutions what u send is working means the datepicker control is working fine on the web.
the other to calculate the differnce i cut the code and put one
button onclick javascript
i paste the code.but i am getting syntax error the curson is at <body> .
so what i have to do.
i want to calculate the difference between the two date fields from which i select from the datepick code.
i think u might have understand my problem.
thanks for sending me very fast reply.one of solutions what u send is working means the datepicker control is working fine on the web.
the other to calculate the differnce i cut the code and put one
button onclick javascript
i paste the code.but i am getting syntax error the curson is at <body> .
so what i have to do.
i want to calculate the difference between the two date fields from which i select from the datepick code.
i think u might have understand my problem.
Hello,
Put the following JavaScript code in the onSubmit event of your form :
var date1 = new Date();
date1.setYear(document.for ms[0].year 1.value);
date1.setMonth(document.fo rms[0].mon th1.value) ;
date1.setDate(document.for ms[0].day1 .value);
var date2 = new Date();
date2.setYear(document.for ms[0].year 2.value);
date2.setMonth(document.fo rms[0].mon th2.value) ;
date2.setDate(document.for ms[0].day2 .value);
var delta = date1.getTime() - date2.getTime();
delta = delta / ( 1000 * 60 * 60 * 24 ); // units are now days.
if (delta < 0) delta = -delta;
delta = Math.round(delta);
if (delta > 21)
{
alert("Difference is more than 21 days!");
return false;
}
else
return true;
This code supposes the following :
On your form you have seperate fields for day, month and year to enter the dates :
Date 1 is build from year1, month1 and day1 fields.
Date 2 is build from year2, month2 and day2 fields.
If the check fails an error message is displayed and the form is not submited. If the check is OK, the form is submitted.
If you have your dates in one field, you need to substract the seperate parts of the date from that field using the substring method in JavaScript.
If you need help with this, I can give you the code, but you need to specify how dates are entered in your form. (dd/mm/yyyy or mm/dd/yyyy or any other way?)
Put the following JavaScript code in the onSubmit event of your form :
var date1 = new Date();
date1.setYear(document.for
date1.setMonth(document.fo
date1.setDate(document.for
var date2 = new Date();
date2.setYear(document.for
date2.setMonth(document.fo
date2.setDate(document.for
var delta = date1.getTime() - date2.getTime();
delta = delta / ( 1000 * 60 * 60 * 24 ); // units are now days.
if (delta < 0) delta = -delta;
delta = Math.round(delta);
if (delta > 21)
{
alert("Difference is more than 21 days!");
return false;
}
else
return true;
This code supposes the following :
On your form you have seperate fields for day, month and year to enter the dates :
Date 1 is build from year1, month1 and day1 fields.
Date 2 is build from year2, month2 and day2 fields.
If the check fails an error message is displayed and the form is not submited. If the check is OK, the form is submitted.
If you have your dates in one field, you need to substract the seperate parts of the date from that field using the substring method in JavaScript.
If you need help with this, I can give you the code, but you need to specify how dates are entered in your form. (dd/mm/yyyy or mm/dd/yyyy or any other way?)
Hi,
Regarding the error,
it appears as though it is an error due to js or the HTML used... Include all js functions that you would like to use in the <Head> tag.
anu
Regarding the error,
it appears as though it is an error due to js or the HTML used... Include all js functions that you would like to use in the <Head> tag.
anu
You can't use the popup calendar screen on the web.
If you want to use a popup calendar tool for selecting dates, you must write it down in Java.
About the time difference.
Do you want the formula for calculating the difference or do you want the formula for the popup or both ?
When must it check the dates, on the moment the user enter a date or every day?
Do you have on your form two date fields, or do you have one time field and the other time field is today.
For showing a message screen on the web you use alert("text")
Greets,
Sloeber