+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : Counting date in specific month by month

  1. #1
    Registered User
    Join Date
    06-14-2012
    Location
    Bangkok
    MS-Off Ver
    Excel 2003
    Posts
    2

    Counting date in specific month by month

    Hi,

    ie. if I have 2 cell and I want to count how many night in a specific month. You can see in the highlight area in attached image
    What is the formula, I should put in

    fomular.jpg

  2. #2
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Counting date in specific month by month

    Row 3 has 0 for June. Why?
    Coudld you attached copy of your spreadsheet for easier calculation?

  3. #3
    Forum Contributor Russell Dawson's Avatar
    Join Date
    03-01-2012
    Location
    Yorkshire, England
    MS-Off Ver
    2007
    Posts
    608

    Re: Counting date in specific month by month

    In A3 put

    =IF(MONTH($A2)=MONTH(C$1),DATE(YEAR($A2),1+MONTH($A2),0)-$A2+1,0)

    Sadly - that's as far as I can go at the moment. This calcs the days from the start to the end of that current month.

    This calc to the end of the month =DATE(YEAR(A2),1+MONTH(A2),0)+1 and needs incorporating

    Have to go offline now but hopefully someone can follow this up.
    If I helped, please don't forget to add to my reputation. (click on the star below the post)

    If the problem is solved, please: Select Thread Tools (on top of your 1st post) -> Mark this thread as Solved.

    Failure is not falling down but refusing to get up.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Counting date in specific month by month

    I manage to do easy if you calculate night from 30.6. to 1.7. as it's night in 7th month...
    Attached Files Attached Files

  5. #5
    Forum Contributor Russell Dawson's Avatar
    Join Date
    03-01-2012
    Location
    Yorkshire, England
    MS-Off Ver
    2007
    Posts
    608

    Re: Counting date in specific month by month

    Very good - a new formula for me to learn - MEDIAN.

    So, if I understand correctly - when used together MEDIAN and DATE
    Please Login or Register  to view this content.
    with DATE +1 it is looking for the two months of the year surrounding the month in C2 (6 - June) and the MEDIAN instruction finds the midway point i.e. in this case the date where the month changes.
    Last edited by Russell Dawson; 06-14-2012 at 04:20 AM.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Counting date in specific month by month

    DATE + 1 will look for last day of current month...

    Therefore DATE(2012, 7, 0) is 30.06.2012 (that's why it's +1)

    MEDIAN return middle value of 3 numbers so it will substract 30.06. - 28.06 = 2
    And look that on second column onward you also have SUM function (or you could leave one empty column and use them in all formulas).

    Edit: Stupid me... Answering your question I figure out that I need just to use DATE(2012, 7, 1) (instead of 0) to get desired result.
    Attached Files Attached Files
    Last edited by zbor; 06-14-2012 at 05:52 AM.

  7. #7
    Registered User
    Join Date
    06-14-2012
    Location
    Bangkok
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Counting date in specific month by month

    Quote Originally Posted by zbor View Post
    I manage to do easy if you calculate night from 30.6. to 1.7. as it's night in 7th month...
    Thank you very very much. I spend 2 days to find out.

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Counting date in specific month by month

    Look post #6, it will give you desired result.

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Counting date in specific month by month

    If you put the 1st of each month in C2 across then you can use this formula in C3 copied across and down

    =MAX(0,MIN(EOMONTH(C$2,0),$B3-1)+1-MAX(C$2,$A3))

    see attached
    Attached Files Attached Files
    Audere est facere

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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