+ Reply to Thread
Results 1 to 6 of 6

Please help with counting days within months

  1. #1
    Registered User
    Join Date
    04-01-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Question Please help with counting days within months

    Hi!

    First of all Im using Excel in another language, Im quite new at this, and I dont know what to search for in the forums (

    Im having two columns with One date when someone moved into an apartment, and the other one when they moved out (or still havent)

    Moving in Moving out
    2012-11-27 2013-01-14
    2012-11-27 2013-01-14
    2012-12-12 2013-01-04
    2013-01-18 2013-03-26
    2013-01-18 2013-03-26
    2013-02-04 Not Yet
    2013-02-10 2013-02-10
    2013-02-18 2013-03-01
    2013-02-18 2013-03-01
    2013-02-26 Not Yet
    2013-03-12 2013-03-25
    2013-03-28 Not Yet
    2013-03-28 Not Yet
    2013-03-28 Not Yet

    I need to sum up, how many nights were rented out in Jan, Feb Mar... etc

    I dont really know what formula to look for, or if this is something that needs to be done in macro or vba even. Maybe Excel has a way to help me with this.


    Thank you SO much in advance, I really apprechiate it!

  2. #2
    Valued Forum Contributor
    Join Date
    07-27-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    826

    Re: Please help with counting days within months

    slan, welcome to the forum.

    Assuming your data is in Columns A & B, in C2 enter: =B2-A2

    and copy down as far as required.

    Hope this helps.
    Brendan.


    __________________________________________________________________________________________________
    Things to consider:

    1) You can thank any poster by clicking the * at the left of a helpful post.
    2) You can help to keep the forum tidy by marking your thread as "Solved", if it has been answered to your satisfaction.
    3) Help us to help you, by uploading a sample workbook, showing the type of data you're dealing with, and clearly indicating what the results should be.

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

    Re: Please help with counting days within months

    I think the requirement is to show the number of days in each month, not just the total days, so if you have start date in A2 and end date in B2 (or "Not Yet") and the first of each month listed in D1 across then try this formula in D2 copied across and down

    =MAX(MIN(EOMONTH(D$1,0),IF($B2="Not Yet",TODAY(),$B2)-1)+1-MAX(D$1,$A2),0)

    For "Not Yet" entries the end date used will be today - see attached

    That doesn't count the end date (like hotel stays) so if you want to count that remove the -1, i.e. use

    =MAX(MIN(EOMONTH(D$1,0),IF($B2="Not Yet",TODAY(),$B2))+1-MAX(D$1,$A2),0)
    Attached Files Attached Files
    Last edited by daddylonglegs; 04-01-2013 at 11:59 AM.
    Audere est facere

  4. #4
    Registered User
    Join Date
    04-01-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Please help with counting days within months

    Wow, that was really fast!
    Thanks alot for your help. The provided example helped really much!

    All I need is the total days (lets say its a kind of hotel) for each month.
    (see attachment)


    Laying up a table like yours and add it together looks like a good way to do it.
    Is that how you should do it? (since I have no use for the table other than adding them up).

    I think I got it now, is it common to make a table like this and then "hide" it somewhere and only use the data youre looking for?

    THANK YOU!!!!

    attachment: TEST5.xlsx

    edit: (working in excel 2010 right now) thats probably why the code was abit different in terms of use of comma and semicolon

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

    Re: Please help with counting days within months

    I think that is a good way to go, you might be able to do it without the table but the calculations will get a lot more complex so I don't recommend that approach.

    The comma/semi-colon issue is because of regional settings, my region (UK) uses comma separators but Sweden uses semi-colons

  6. #6
    Registered User
    Join Date
    04-01-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Please help with counting days within months

    Another question regarding same matter.

    Lets says I want a graph that shows How many people have stayed each day? (2013-01-01 should be 3 according to the provided example above and 2013-01-15 should show 0.)
    In my mind I have to check every specific date to see if it is between the range of the stay on every single column and add it together?
    I really have no idea where to go with this one.

    A hint or a solution would be wonderful.

+ 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