Calculating dates

  • Thread starter Thread starter Dimas
  • Start date Start date
D

Dimas

Is it possible to calculate the difference in months
between two different years? Example how many months
between today's date and december of any year not
including the number oy years? Example between May of
2003 and April 2003 are 13 months, but in reality there
is only one month between April and May.
 
Dimas

This seems to work...
=ABS(MONTH(B1)-MONTH(A1))

This custom function returns the name of the month that is M months away (+
or -)...
'------------------------------------------
Function THEMONTH(ByVal M As Long) As String
On Error GoTo NoDate
Dim Months As Variant
Dim PickOne As Integer
Months = Array("December", "January", "February", "March", "April",
"May", _
"June", "July", "August", "September", "October",
"November")
PickOne = (M + Month(Date)) Mod 12
If PickOne >= 0 Then THEMONTH = Months(PickOne) Else _
THEMONTH = Months(PickOne + 12)
Exit Function

NoDate:
THEMONTH = "Error " & Err.Number
End Function
'------------------------------------------
Regards,

Jim Cone
San Francisco, CA
*******************************
 
another thought
create a function

Function dd(a As Date, b As Date)
Application.Volatile
dd = DateDiff("m", a, b)
End Function
 
Back
Top