wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Date Difference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Date Difference" Watch "Date Difference" New topic
Author

Date Difference

rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
I have 3 text fields.
Through date picker i insert start date in one text field and end date in another text field.
I want to know how do display the difference of these 2 dates in form of days in the third text field.
Can anyone help?
Thanx
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
Hi..
I am posting a code which will be helpful to yu..If ne queries behind these code feel free to ask...

regards,
Nischal


Thnx
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Hi,
I have code in jsp file like this..
-----------------------------

input id="txtstartdate" type="text" name="txtstartdate" size="12"

input id="txtenddate" type="text" name="txtenddate" size="12"
input id="txtndays" type="text" name="txtndays" size="7" ------------------------------------
Now thru date picker i get start date and end date....
And the difference of the days between these 2 dates should be displayed in the third text field.
Thanx
Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182

I hope this helps u...I have used SimpleDateFormat to parse the given String into a date object and the rest is same..U will have to restrict the user to insert date in s scpecific format..This can b done through javascript..
regards,
Nischal
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Thanx a lot.
rose hegde
Ranch Hand

Joined: Oct 22, 2003
Posts: 40
Actually i want to find difference of 2 dates in frontend..javascript..!!
And when i enter start date and end date through date picker..on jsp page..than automatically the 3rd field should be displayed with no of days between the dates..
Thanx
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60817
    
  65

Actually i want to find difference of 2 dates in frontend..javascript..!!

In that case I'm going to shuffle this off the HTML/Javascript forum.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6

See if this helps
Eric
 
Consider Paul's rocket mass heater.
 
subject: Date Difference
 
Similar Threads
Problem with javascript dates
Calender Object
date validation in javascript
How to make Change in text field whenever i choose a date from calender image.
h:outputText: Default Value