+ Reply to Thread
Results 1 to 7 of 7

Number of days passed in a month

  1. #1
    Registered User
    Join Date
    12-30-2012
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    31

    Number of days passed in a month

    Hi All,

    I need to find the below and wondering how do i write a formula for this.

    Consider today as 25-Mar-2021 and so the March month should show me 25 days and since April is yet to start so it should show as Zero. For the other months since they have passed so they should show all days.

    Month Days Passed
    2021-01 31
    2021-02 28
    2021-03 25
    2021-04 0


    Thanks all,
    Rgds, AK

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

    Re: Number of days passed in a month

    assum Month in column A and Days in column B
    Are month "2021-01" text or real date formatted as "yyyy-mm"?

    If they are real dates:

    use in B2:
    =IF(TODAY()>=EOMONTH(A2,0),DAY(EOMONTH(A2,0)),IF(TODAY()>EOMONTH(A2,-1),DAY(TODAY()),0))

    or
    =IF(TODAY()<=EOMONTH(A2,-1),0,DAY(MEDIAN(TODAY(),EOMONTH(A2,-1),EOMONTH(A2,0))))

    or
    =(TODAY()>EOMONTH(A2,-1))*DAY(MEDIAN(TODAY(),EOMONTH(A2,-1),EOMONTH(A2,0)))

    If they are text like this: "2021-01", try to replace A2 by DATEVALUE(A2&"-1"):

    =IF(TODAY()>=EOMONTH(DATEVALUE(A2&"-1"),0),DAY(EOMONTH(DATEVALUE(A2&"-1"),0)),IF(TODAY()>EOMONTH(DATEVALUE(A2&"-1"),-1),DAY(TODAY()),0))

    or

    =IF(TODAY()<=EOMONTH(DATEVALUE(A2&"-1"),-1),0,DAY(MEDIAN(TODAY(),EOMONTH(DATEVALUE(A2&"-1"),-1),EOMONTH(DATEVALUE(A2&"-1"),0))))

    or

    =(TODAY()>EOMONTH(DATEVALUE(A2&"-1"),-1))*DAY(MEDIAN(TODAY(),EOMONTH(DATEVALUE(A2&"-1"),-1),EOMONTH(DATEVALUE(A2&"-1"),0)))
    Last edited by bebo021999; 03-29-2021 at 11:29 PM.
    Quang PT

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Number of days passed in a month

    Maybe:

    =iIFERROR(MIN(TODAY()-A2,DAY(EOMONTH(A2,0)),0)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

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

    Re: Number of days passed in a month

    Look promise.

    May be MIN then MAX?

    =max(min(...),0)

    to returns zero for Apr and later months.
    Last edited by AliGW; 03-30-2021 at 03:16 AM. Reason: PLEASE don't quote unnecessarily!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Number of days passed in a month

    Yes, this is better:

    =MAX(MIN(TODAY()-A2,DAY(EOMONTH(A2,0))),0)
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Number of days passed in a month

    IF today is counted as a day which appears to be the case in the example, on the 25th the answer is 25, so a slight tweak of the above hard work, I think the below works

    =MEDIAN(TODAY()-A2+1,DAY(EOMONTH(A2,0)),0)

  7. #7
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Number of days passed in a month

    If month column is in text format in C2 then copy down

    =MAX(MIN(TODAY(),EOMONTH(DATE(LEFT(A2,4)+0,MID(A2,6,2)+0,1),0))-DATE(LEFT(A2,4)+0,MID(A2,6,2)+0,1)+1,0)

    If month column is in date format in H2 then copy down

    =MAX(0,MIN(TODAY(),EOMONTH(G2,0))-G2+1)
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 03-30-2021 at 10:56 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

+ 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: 3
    Last Post: 04-18-2018, 04:17 AM
  2. [SOLVED] No of Days Passed in current month based on =Today() Function
    By kskhan1105 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-06-2017, 10:16 AM
  3. [SOLVED] Calculate number of days that have passed
    By MSE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-05-2016, 12:39 PM
  4. [SOLVED] Working days passed & left in the month / week
    By nagesh.tvsr in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-13-2015, 07:56 AM
  5. Formula to show how many days have passed since the last day of the month
    By baby_gizmo87 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-13-2014, 09:03 AM
  6. [SOLVED] Dynamically calculate days that have passed in a month
    By sbaipsys in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-08-2012, 05:57 PM
  7. Number of days passed monthly/yearly
    By cell-dweller in forum Excel General
    Replies: 2
    Last Post: 06-20-2010, 10:31 PM

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