+ Reply to Thread
Results 1 to 13 of 13

count days that fall within specified quarter from large range

  1. #1
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    count days that fall within specified quarter from large range

    Hello,

    I am trying to write a formula to pull in the # of days that fall within a quarter- that are in a larger range. In other words, I have contracts that span over years with different start and end dates and I would like to return how many days they fall within Q1.

    Cell B2 start date 1/1/2016 Cell C2 end date 3/31/2016

    Cell B4 Effective Date
    Cell C4 Expiration Date

    I am trying to use a countif but having trouble. I am trying to return the dates in Q1 2016 in column D

    Capture.PNG

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: count days that fall within specified quarter from large range

    Try this in D4

    =MAX(0,MIN(C4,$C$2)-MAX(B4,$B$2)+1)

  3. #3
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: count days that fall within specified quarter from large range

    OMg yes!!!! thank you so much!

    Would you by chance be able to explain the formula in english so I could understand/explain it?

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,061

    Re: count days that fall within specified quarter from large range

    In D4, copied down:

    =1+IF(C4>=$C$2,$C$2,C4)-IF(B4>=$B$2,B4,$B$2)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,061

    Re: count days that fall within specified quarter from large range

    Oops. i forgot to refresh before posting...

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: count days that fall within specified quarter from large range

    Quote Originally Posted by amajor99 View Post
    OMg yes!!!! thank you so much!

    Would you by chance be able to explain the formula in english so I could understand/explain it?
    You're welcome. Happy to help.

    The formula subtracts the latest date (between B4 and B2) from the earliest date (between C4 and C2). The +1 makes sure to include the start date in the count.
    The "MAX(0" section is an error handler in the case where "MIN(C4,$C$2)-MAX(B4,$B$2)+1" is negative.

    If this solved your question, please mark this thread as SOLVED.

  7. #7
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: count days that fall within specified quarter from large range

    Hi- sorry I am getting an error when I did a quick gut check. in line 11 (highlighted in yellow) the managed spend days are still returning 91 days even though the contract dates are 2013-2014 and the quarter I want to return is Q1 of 2016. Do you know how to fix? Error.PNG

  8. #8
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: count days that fall within specified quarter from large range

    Can you attach your workbook so that we can take a closer look?

    As you can see from my attachment, it is working fine on my end.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: count days that fall within specified quarter from large range

    I'm not able to attach a file. I have the same formula in as your workbook. I have macros enabled and am using office 2013. Anything I should know?

  10. #10
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: count days that fall within specified quarter from large range

    It's something to do with my pulling the dates in from another tab- if I do =tabdata!B2 to pull the date in the formula just sets to 91

  11. #11
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: count days that fall within specified quarter from large range

    To attach a file, select Go Advanced > Manage Attachments > Choose File > select the file then "Open" > Upload > Close this window > Submit Reply.

    Maybe automatic calculations are turned off? To test this, double click on cell E11 then press Enter and see if you get 0.

  12. #12
    Registered User
    Join Date
    07-05-2017
    Location
    chicago
    MS-Off Ver
    Office 2013
    Posts
    44

    Re: count days that fall within specified quarter from large range

    ok here we go
    Attached Files Attached Files

  13. #13
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: count days that fall within specified quarter from large range

    Your dates are being seen as text. Simply highlight column A > Data > Text to Columns > Finish.

    Do the same for column B.

+ 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. Count the number of days that fall within a particular month.
    By Portuga in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-30-2008, 04:26 PM
  2. how would I count dates (not # of days) in cells that fall betwee.
    By sailingscotts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  3. how would I count dates (not # of days) in cells that fall betwee.
    By Max in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 05:05 PM
  4. how would I count dates (not # of days) in cells that fall betwee.
    By sailingscotts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 PM
  5. how would I count dates (not # of days) in cells that fall betwee.
    By sailingscotts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM
  6. how would I count dates (not # of days) in cells that fall betwee.
    By sailingscotts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  7. [SOLVED] how would I count dates (not # of days) in cells that fall betwee.
    By Max in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 06:05 AM
  8. how would I count dates (not # of days) in cells that fall betwee.
    By sailingscotts in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM

Tags for this Thread

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