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 How to calculate difference between two dates in months Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to calculate difference between two dates in months" Watch "How to calculate difference between two dates in months" New topic
Author

How to calculate difference between two dates in months

Sudarshan Reddy
Greenhorn

Joined: Aug 23, 2007
Posts: 20
Hi
can any one tell how to calculate difference between two dates in months?


With Regards<br /> <br />Sudarshan Reddy
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Depends on the DB used. Just consult the SQL documentation which comes along it. If you're using for example MySQL, you can use the DATEDIFF function for this.
Sudarshan Reddy
Greenhorn

Joined: Aug 23, 2007
Posts: 20
i am using the mysql DB

datediff function getting difference in dates but i need in months between two dates..?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Use TIMESTAMPDIFF.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to calculate difference between two dates in months
 
Similar Threads
Calculate date difference [Gregorian calender]
Date
Problem in setting the date in a servlet
how do I find date difference in months
calculate difference in months