|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Date Difference
Posted by Joe on November 07, 2001 at 3:30 AM
Hi, i don't know if this can help u. if the 2 dates are 2 columns in a database u want to extract and calculate the difference then my reply will help u. i search in java a function that calculate the difference between 2 dates i didn't found, so i use the following query to access the database, extract the value of 2 dates and calculate the difference. Dat = rset1.getDate("Date"); //value of first date Dat1 = rset2.getDate("Date"); //value second date stmt3.executeUpdate("Update tableName set Difference = abs(DateDiff('d', ' " + Dat + " ', ' " + Dat1 + " ' ))"); // executeQuery Diferece is a column in the table that will contain the difference. DateDiff is the function that calculate the diff, 'd' specifie that the difference is day diff between the 2 dates. hope that it will help.
Replies:
|