1. COUNTING MONTHS

I have a spreadsheet which indicates the start and end dates of people hired on a contract basis. Is there a way of automatically calculating the number of months they will be employed.

2. Re: COUNTING MONTHS

If the start date is in cell B1 and the end date is in cell B2, then the following formula should return the 'inclusive' number of months:

=12*(YEAR(B2)-YEAR(B1))+(MONTH(B2)-MONTH(B1))+1

By inclusive I mean that both the starting and the ending months are included. Also, the above formula ignores the starting and ending days.

3. Re: COUNTING MONTHS

Here is a VBA function that will calculate it for you:

<pre>Public Function GetMonths(dStart As Date, dEnd As Date) As Long
Dim dW As Integer
GetMonths = DateDiff("m", dStart, dEnd)
End Function
</pre>

4. Re: COUNTING MONTHS

Hi,
You can use DateDif to return the number of complete months between two dates:
=datedif(startdate,enddate,"m")
but note that this will not count partial months - e.g. if start date is 2nd Jan and end date is 1st Feb it will return 0 months.
Hope that helps.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•