PC Review
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Setup
Calculating dates
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Setup
Calculating dates
![]() |
Calculating dates |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 ******************************* "Dimas" <dimas@optonline.net> wrote in message news:06d601c33d7b$8803fba0$a501280a@phx.gbl... > 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. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
another thought
create a function Function dd(a As Date, b As Date) Application.Volatile dd = DateDiff("m", a, b) End Function >-----Original Message----- >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. >. > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

