• 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.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!