Month Date Difference in T-SQL

What I am looking for is the difference in months with days taken into consideration.  Ex:  "07/30/1999" and "08/01/1999" should give me a difference of 0 months.  What is the most efficient way to do this?

The T-SQL function DATEDIFF(datepart, date1, date2) would return a 1.

Thank You.
Jim
jzupkusAsked:
Who is Participating?
 
simonsabinConnect With a Mentor Commented:
This is the only way I can think of at the moment

declare @start datetime, @end datetime
select @start = "30/7/1999",@end = "31/8/1999"

select Case When datepart(dd,@start) <datepart(dd,@end) Then datediff(mm,@start,@end)  Else datediff(mm,@start,@end) -1 end
0
 
Gandalf32Commented:
How about:
datediff(dd, date1, date2) / 30
This would only work for a difference < 6 years.
0
All Courses

From novice to tech pro — start learning today.