I have two textboxes i used calender control extender. I want to compare two dates and display no of days. using javascript how to compare in javascript i want how can i write.
please help
thanq.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kiranpreet ChawlaPosted Sep 27, 2011, 2:19 AM
runat="server"
TargetControlID="TextBox1"
PopupButtonID="btnCalenderPopup"
OnClientDateSelectionChanged="checkDate"
Format="dd/MM/yyyy" />
As shown, implement the OnClientDateSelectionChanged event, and call "checkDate" function. Define this function in javascript as shown:
And then,To find the number of days between any two dates , use following javascript:
var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
var firstDate = new Date(2008,01,12);
var secondDate = new Date(2008,01,22);
var diffDays = Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay));
This will give you number of days between two dates.
Thanks.
If this helped you. Please mark it as an ANSWER.
Jaganathan BantheswaranPosted Sep 27, 2011, 2:03 AM
Here you can get some idea about this.
Comaprission of dates for a year in JavaScript