Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to calculate difference between two dates in months

 
Sudarshan Reddy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
can any one tell how to calculate difference between two dates in months?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using the mysql DB

datediff function getting difference in dates but i need in months between two dates..?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use TIMESTAMPDIFF.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic