# Calculating Months for Billing Purposes

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Calculating Months for Billing Purposes.

Olga keeps the books for a private school. For each student enrolled, she has an entry date and a drop date. She needs to figure out how many months to bill each student. If the student was in class for at least five days, that month should be included in the billing. If less than five days, they are not billed for that month. She also needs to exclude holidays and weekends.

Integral to any solution to this problem is going to be the use of the NETWORKDAYS function. This function, as described in other ExcelTips, is part of the Analysis ToolPak. Assuming you have the ToolPak enabled, the function will calculate the net number of work days between two dates. It takes into account weekends and, optionally, holidays.

So, assuming you have the student's entry date in A1 and the drop date in A2, the only thing you need to do is set up a list of holidays. You can do that by simply starting to enter the holidays in a range of cells. Enter one date per cell, and then select the range. Define a name to refer to the range, such as MyHolidays.

You can then use a formula such as the following:

```=(NETWORKDAYS(A1, DATE(YEAR(A1), MONTH(A1) + 1,0), MyHolidays) >= 5)
+ (NETWORKDAYS(DATE(YEAR(A2), MONTH(A2),1), A2, MyHolidays) >= 5)
+ DATEDIF(DATE(YEAR(A1), MONTH(A1) + 1, 1), DATE(YEAR(A2),
MONTH(A2), 1), "m")
```

The formula is quite long, and bears some examination. Note that besides the NETWORKDAYS function, it also uses the DATEDIF function, which is used to determine the difference between two dates and return the interval in different ways. In this instance, it is used with the "m" parameter, which means it returns the interval as a number of months—exactly what is needed by Olga.

The first part of the formula (the first use of the NETWORKDAYS function) is used to determine how many days there are between the entry date (in cell A1) and the end of the month in which the entry date occurs. If this value is greater than or equal to 5 (Olga's cutoff), then the value 1 is returned, since this counts as a single billable month.

The next part of the formula (the second use of the NETWORKDAYS function) is used to determine whether there are at least five class days in the month in which the drop date occurs. If so, then the value 1 is returned, again because this is a billable month.

The DATEDIF function is then used to return the number of full months between the entry month and the drop month. What you end up with is a count of the number of months that should be billed for the student.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3271) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Calculating Months for Billing Purposes.

Related Tips:

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

 *Name: Email: Notify me about new comments ONLY FOR THIS TIP Notify me about new comments ANYWHERE ON THIS SITE Hide my email address *Text: *What is 5+3 (To prevent automated submissions and spam.)

Dave    01 May 2014, 09:24
I use Excel 97 and DATEDIF does not appear in the list of functions when I use Shift+F3.

Do you have a workaround for this?

# Our Company

Sharon Parq Associates, Inc.

# Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Excel Products

Word Products

# Our Authors

Author Index

Write for Tips.Net