+ Reply to Thread
Results 1 to 11 of 11

Return the number of days in a month from a data set

  1. #1
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Return the number of days in a month from a data set

    Hi all, I have some data & want to count the individual number of days for each month.

    Example attached..
    Attached Files Attached Files
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.

  2. #2
    Registered User
    Join Date
    04-08-2014
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Return the number of days in a month from a data set

    try this. hth
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Re: Return the number of days in a month from a data set

    Thanks for the reply, not sure how it relates to my problem..

    MQ

  4. #4
    Registered User
    Join Date
    04-08-2014
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Return the number of days in a month from a data set

    oh sorry. i looked at it too quick & misunderstood what you were solving for...

    so you want to know how many Apr 1st's appear in this list (for example) right? or did you want how many days per each month appear in the list? either way, try this.

    tmp.solved.xlsx

  5. #5
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Re: Return the number of days in a month from a data set

    Neither of those. The answer for April is 22 because of the 30 days in April 22 of them appear in my data.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,747

    Re: Return the number of days in a month from a data set

    pickslides, I believe you are asking how many unique dates are listed for each month.

    Your data has some problems. All of your dates for April (except April 3 and 4) are text, not dates, making this process extremely difficult to resolve. I think you may have some localization issue where Excel doesn't recognize 14/4/2014 in Aussie format as a valid date, and so it is interpreted as text. Or you may have actually entered them as text to start with. I'm not sure.

    Also, whenever dealing with dates, it is always better to use actual dates. In C7:C10, you have typed in month names as text. If you want to count dates for each month, it is going to be better for these to be dates so you can test the dates in your list against these dates. For example, use 1/4/2014 for April (assuming Aussie date format), then use formatting to display "April".

    Once you have your data corrected I can look at how to do the counts. It is going to require an array formula.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  7. #7
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Return the number of days in a month from a data set

    Once you have the dates corrected as per 6StringJazzer's post above, and changed the months in column c to dates as well (formatted to Mmm to retain same look) the following will work as an array formula (Ctrl+Shift+Enter).
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by gak67; 05-07-2014 at 10:14 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Return the number of days in a month from a data set

    But if it is just weekend days that are not included in your data a simpler formula would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Return the number of days in a month from a data set

    Please see attached file with date converting formula and unique dates calculations.
    Attached Files Attached Files
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  10. #10
    Registered User
    Join Date
    04-08-2014
    Location
    Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    29

    Re: Return the number of days in a month from a data set

    Quote Originally Posted by 6StringJazzer View Post
    pickslides, I believe you are asking how many unique dates are listed for each month.

    Your data has some problems. All of your dates for April (except April 3 and 4) are text, not dates, making this process extremely difficult to resolve. I think you may have some localization issue where Excel doesn't recognize 14/4/2014 in Aussie format as a valid date, and so it is interpreted as text. Or you may have actually entered them as text to start with. I'm not sure.

    Also, whenever dealing with dates, it is always better to use actual dates. In C7:C10, you have typed in month names as text. If you want to count dates for each month, it is going to be better for these to be dates so you can test the dates in your list against these dates. For example, use 1/4/2014 for April (assuming Aussie date format), then use formatting to display "April".
    @6StringJazzer, thanks for explaining the inconsistent raw date inputs - i noticed it too but hoped if OP saw that the month in text format or the pivot was not counting them as USA date formats dates as expected, he could elaborate/make changes needed to fix the formulas i provided (fyi - in fairness I added the 1st col with month as text MMM, to facilitate the countifs per each month)

    You are so right about DATES they are TRICKY TRICKY little DEVILS in the programming world, no matter what code language you are writing them in! it was an eye-opener to me as i discovered how complicated they can be when i was first learning .NET programming in VB and JS. Excel is certainly no exception - maybe even more complicated in some ways.

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Return the number of days in a month from a data set

    Thank you for the feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 12
    Last Post: 02-08-2013, 02:26 PM
  2. [SOLVED] how to return a day(number) by selecting month and year from data list
    By lizsantiago07 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-24-2012, 02:43 PM
  3. [SOLVED] Number of Days Between Dates but if no Date go to next and return # of Days
    By Bikeman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-14-2012, 12:02 PM
  4. Replies: 4
    Last Post: 03-01-2012, 04:27 PM
  5. Replies: 3
    Last Post: 09-25-2007, 10:26 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1