File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Format date using jsp to save into mysql DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Format date using jsp to save into mysql DB" Watch "Format date using jsp to save into mysql DB" New topic
Author

Format date using jsp to save into mysql DB

vanan saravanan
Ranch Hand

Joined: Jun 02, 2006
Posts: 95
This is the problem i have. I have two textfields. Start date and end date. I use a date picker to enter the value into the textfields. The values are then stored into a mysql database. This part works fine. I got 3 fields in my database. A startdate, enddate and duration. My question is how do i find out the duration if i have two dates in two textfields.

Example

Textfield 1 : 13-06-2006
Textfield 2 : 16-06-2006
Duration = 3 days (How do i calculate this)

I solved the above using the below mentioned code.
<script type="text/javascript">
<!--
function checkdate() {
var begDate = new Date(document.demoform.dc1.value);
var endDate = new Date(document.demoform.dc2.value);
var difDate = endDate.getTime() - begDate.getTime();
var days = difDate / (24*60*60*1000);
alert(days);
}
//-->
</script>

The problem is it does not work with this format. DD-MM-YYYY. Is it possible for me to use jsp and find out the difference between the days and save it to the mysql database. Thank you for your help.
vanan saravanan
Ranch Hand

Joined: Jun 02, 2006
Posts: 95
Managed to solve the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Format date using jsp to save into mysql DB