+ Reply to Thread
Results 1 to 9 of 9

count no of days with condition

  1. #1
    Registered User
    Join Date
    02-23-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    3

    Question count no of days with condition

    I want to calculate no of days in adjacent cell with following condition for the period of 10 years

    (If day of month is 4th
    Then count no. of days from last 21st to 4th ………. “no of days varies from 12 to 15”
    If day of month is 20th
    Then count no. of days from last 5th to 20th ……… “no of days are 16”
    Else
    Null)

    Dates are in the following format

    1-Jan-17
    2-Jan-17
    3-Jan-17
    4-Jan-17 15 Days
    5-Jan-17
    6-Jan-17
    .
    .
    20-Jan-17 16 Days
    .
    .
    29-Dec-26
    30-Dec-26
    31-Dec-26


    Regards,

    Sandesh

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: count no of days with condition

    Hi Sandesh
    try this:

    Please Login or Register  to view this content.

  3. #3
    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,023

    Re: count no of days with condition

    Just a modification to the above...

    =IF(DAY(A1)=20,A1-DATE(YEAR(A1),MONTH(A1),5)+1,IF(DAY(A1)=4,A1-DATE(YEAR(A1),MONTH(A1)-1,21)+1,""))
    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

  4. #4
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: count no of days with condition

    B1=IF(DAY(A1)=4,A1-EOMONTH(A1,-2)-20,IF(DAY(A1)=20,A1-EOMONTH(A1,-1)-4,""))
    If your data starts from A1 then try the above formula in B1 and copy towards down
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  5. #5
    Registered User
    Join Date
    02-23-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    3

    Re: count no of days with condition

    Thanks Nicky,

    It is very near to may solution but this formula returns value with one day less please see my post.
    for date 20-jan-17 I want 16 days...this formula giving 15 days.

    could you help me in this

  6. #6
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Slough
    MS-Off Ver
    Excel 2007
    Posts
    469

    Re: count no of days with condition

    Are you including the current day as well? Just + 1

  7. #7
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: count no of days with condition

    Hi
    I think Glen's changes will give you what you want

  8. #8
    Registered User
    Join Date
    02-23-2017
    Location
    INDIA
    MS-Off Ver
    2016
    Posts
    3

    Re: count no of days with condition

    Thanks Siva...

    your formula is working for all conditions.....

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: count no of days with condition

    Another solution:

    =IF(DAY(A1)=20,16,IF(DAY(A1)=4,A1-EOMONTH(A1,-2)-20,""))

    P/S: From 5th to 21st = 16, constant for every month, right?
    Last edited by bebo021999; 02-24-2017 at 05:50 AM.
    Quang PT

+ 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. Trying to create a formula to count days based on 8 hour days
    By meadnl89 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-03-2016, 06:41 PM
  2. [SOLVED] Count number of days according to a condition
    By tsakta13ole in forum Excel General
    Replies: 5
    Last Post: 10-06-2015, 08:41 AM
  3. Replies: 17
    Last Post: 08-03-2015, 06:15 AM
  4. [SOLVED] Count 6 working days (excluding Sunday, Holidays & half days)
    By eve_star1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-29-2015, 08:00 AM
  5. Count unique days on condition that they are Mondays
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2012, 12:11 PM
  6. Replies: 8
    Last Post: 07-13-2012, 09:02 AM
  7. Calculating time elapsed in days and count days within same range
    By michellem410 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-19-2008, 01:13 PM

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