Click here to Skip to main content
15,899,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have from date and to date
need to find no days from javascript??
e.g 30-3-2010 to 2-4-2010 like this

basically
SQL
using gridview in asp.net with c#

three are 2 cols from date and to date where user can select the date??

I need to find no of days by javascript by onblur method ???

to calculate it
Posted
Updated 1-Apr-10 21:19pm
v2

Find js code here

C#
function DateDifference(date1, date2){
var day=1000*60*60*24;
//Calculate difference btw the two dates, and convert to days
return (Math.ceil((date1-date2)/day));
}


Just you need pass your dates in this method and it will return you days difference.
 
Share this answer
 
It looks like Javascript doesn't provide a timespan object, hence you have to write your own function. It shouldn't be too difficult, what is your trouble about?
:)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900