PC Review Forums Newsgroups Microsoft Excel Microsoft Excel Setup Calculating dates

Reply

Calculating dates

 
Thread Tools Rate Thread
Old 28-06-2003, 01:45 PM   #1
Dimas
Guest
 
Posts: n/a
Default Calculating dates


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.
  Reply With Quote
Old 28-06-2003, 10:01 PM   #2
Jim Cone
Guest
 
Posts: n/a
Default Re: Calculating dates

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.



  Reply With Quote
Old 28-06-2003, 11:59 PM   #3
Lance
Guest
 
Posts: n/a
Default Calculating dates

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.
>.
>

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off