Counting Jobs Completed On a Date

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: Counting Jobs Completed On a Date.

Rob keeps statistics on each job he completes each day. For instance, he tracks the exact number of hours and minutes spent on each job by entering a start time (column B) and finish time (column C) for each job in the format: 05/16/11 11:25 am. In a separate column (column G) he has the date for each day of the month. To the right of each date (in column H) he wants to show how many jobs he completed on each of the calendar dates. Rob wonders what formula he would use to figure out this count.

This task is not as easy as it might seem at first. The reason is because of the way in which the start and end times are being stored. Column B contains both the start date and time in the same column, in the format "05/16/11 11:25 am" and column C contains both the ending date and time in the same format. You might think you can use the COUNTIF function in column G, in this manner:

```=COUNTIF(C\$2:C\$1000,G2)
```

This won't work, however. The reason is simple—column G (cell G2, in this instance) contains a date, with no time. For instance, it might contain the date 05/16/11. When this is compared to cell C2, which might contain 05/16/11 11:25 am, they are not the same. Remember that Excel is doing the comparison based on the date and time serial number stored in each cell. Given the example values just mentioned, cell G2 would contain a serial number of 39217 and cell C2 would contain a serial number of 39217.47569. Since these two values are not the same, COUNTIF doesn't count them as equal.

Obviously one solution would be to add another column that contained only the ending dates for each job, without a time. Then you could use the COUNTIF function in your formula since you'd be comparing "apples to apples," so to speak. But there is a solution that doesn't require using an intermediate result in a new column. It involves making sure that the integer value of whatever is in column C is compared with the dates stored in column G. This can be done by using the SUMPRODUCT function, in this manner:

```=SUMPRODUCT((INT(C\$2:C\$1000)=G2)*1)
```

The integer of each of the values in the range C2:C1000 is compared to the date in G2, giving an array of True and False values. Multiplying each of these by 1 turns the True and False values into 1 and 0 values, respectively. The formula then sums these products, giving the desired count.

If you prefer, you could also use the following formula, which performs essentially the same task using SUMPRODUCT:

```=SUMPRODUCT(--(INT(C\$2:C\$1000)=G2))
```

One of the benefits of using the SUMPRODUCT function to determine a result is that you don't need to use an array formula. Some people, however, prefer to use array formulas. If you like to use them, then you can use either of the following:

```=COUNT(IF(INT(C\$2:C\$1000)=INT(G2),1,FALSE))
=SUM(IF(ROUND(C\$2:C\$1000,0)=G2,1,0))
```

Remember that array formulas must be entered into a cell using Ctrl+Shift+Enter.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10421) 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: Counting Jobs Completed On a Date.

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

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)

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