MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 12th, 2004, 06:08 AM   #1
zanzi
 
Join Date: May 2004
Posts: 2
Default Counting unique Dates without the time affecting the outcome

I am trying to count the number of days worked in a list the has different activities listed at different times in the day. Because of the different times in a single day I am having trouble getting a count of the days only.

I used a formula from another posting ......

=SUM(IF(LEN(B29:B100),1/COUNTIF(B29:B100,B29:B100)))

but it treats each date and time as a unique entity. I need to just count the days but am stuck with data that also has times attached. Is there any way around this?

example

4/12/04 12:00 AM
4/12/04 12:00 AM
4/13/04 12:00 AM
4/13/04 5:57 PM
4/13/04 8:37 PM
4/14/04 12:00 AM
4/14/04 6:26 PM
4/14/04 6:28 PM
4/14/04 6:28 PM
4/15/04 12:00 AM
4/15/04 7:29 PM
4/15/04 7:29 PM
4/16/04 12:00 AM
4/16/04 8:37 PM
4/17/04 12:00 AM
4/17/04 3:52 PM
zanzi is offline   Reply With Quote
Old May 12th, 2004, 06:16 AM   #2
Todd Bardoni
 
Todd Bardoni's Avatar
 
Join Date: Aug 2002
Location: Rochester, MI USA
Posts: 3,044
Default Re: Counting unique Dates without the time affecting the out

Try:-

=TEXT(A1,"mm/dd/yyyy")

in your formula to covert it to a date only.
__________________
Todd


"I'm a Data Anlyst(intermediate) and have no idea what it's all about."
Todd Bardoni is offline   Reply With Quote
Old May 12th, 2004, 06:24 AM   #3
Dick Kusleika
 
Join Date: May 2004
Location: Omaha
Posts: 40
Default Re: Counting unique Dates without the time affecting the out

tbardoni

Try this one

=SUM(IF(LEN(B29:B100),1/(COUNTIF(B29:B100,"<"&INT(B29:B100)+1)-COUNTIF(B29:B100,"<"&INT(B29:B100)))))
__________________
Dick Kusleika
www.dicks-blog.com
Dick Kusleika is offline   Reply With Quote
Old May 12th, 2004, 06:29 AM   #4
zanzi
 
Join Date: May 2004
Posts: 2
Default Re: Counting unique Dates without the time affecting the out

Thanks

Where should I insert your formula ?
zanzi is offline   Reply With Quote
Old May 12th, 2004, 06:31 AM   #5
Todd Bardoni
 
Todd Bardoni's Avatar
 
Join Date: Aug 2002
Location: Rochester, MI USA
Posts: 3,044
Default Re: Counting unique Dates without the time affecting the out

Sure, just give him the answer why don't ya.

Looks good.
__________________
Todd


"I'm a Data Anlyst(intermediate) and have no idea what it's all about."
Todd Bardoni is offline   Reply With Quote
Old May 12th, 2004, 06:32 AM   #6
Todd Bardoni
 
Todd Bardoni's Avatar
 
Join Date: Aug 2002
Location: Rochester, MI USA
Posts: 3,044
Default Re: Counting unique Dates without the time affecting the out

Quote:
Originally Posted by zanzi
Thanks

Where should I insert your formula ?
Hey hey! We don't tolerate that kind of talk around here.
__________________
Todd


"I'm a Data Anlyst(intermediate) and have no idea what it's all about."
Todd Bardoni is offline   Reply With Quote
Old May 12th, 2004, 06:37 AM   #7
Dick Kusleika
 
Join Date: May 2004
Location: Omaha
Posts: 40
Default Re: Counting unique Dates without the time affecting the out

Sorry tbardoni, I meant to address that to zanzi. It's my first day, and I haven't figured out that I should refresh my browser once in a while.
__________________
Dick Kusleika
www.dicks-blog.com
Dick Kusleika is offline   Reply With Quote
Old Jun 22nd, 2004, 09:23 PM   #8
jlu21
 
Join Date: Jun 2004
Posts: 3
Default Re: Counting unique Dates without the time affecting the out

Hi,

Does anyone have any suggestions if the range is not fixed? ie. in the example above, if you're passed a start date and an end date, how many unique days are there between 4/13/04 and 4/15/04? How many between 4/14/04 and 4/17/04? etc.
jlu21 is offline   Reply With Quote
Old Jun 22nd, 2004, 09:32 PM   #9
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 42,648
Default Re: Counting unique Dates without the time affecting the out

Quote:
Originally Posted by jlu21
Hi,

Does anyone have any suggestions if the range is not fixed? ie. in the example above, if you're passed a start date and an end date, how many unique days are there between 4/13/04 and 4/15/04? How many between 4/14/04 and 4/17/04? etc.
Question 1: What do you have -- date/time values or just date values?

Question 2: Are the values sorted in ascending order?
Aladin Akyurek is offline   Reply With Quote
Old Jun 22nd, 2004, 10:14 PM   #10
jlu21
 
Join Date: Jun 2004
Posts: 3
Default Re: Counting unique Dates without the time affecting the out

Only date values. (mm/dd/yyyy)

The data can be sorted in ascending value, but I am trying to figure out a solution flexible enough to accomodate it if one or two date records are out of order.

I kinda have a rough solution, combining the code provided above, and also using the MATCH function to determine the first and last row ids of the range, and then concatenating the fields to create a range, but it's not very clean, and I'm sure there are situations where it may not be accurate. (ie. when the data is not in ascending order)
jlu21 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 04:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2010 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes