Skip to content

The Geek Worker

Random Computer Issues And Things That Fixed Them For Me

  • About this Website
  • Helpful Links

Excel Formula to get Number of Days in a Month

January 18, 2012 by geekworker1 min read

It seems Excel still can’t tell me the days in a particular month.

The following formula works, though:

=DAY(DATE(YEAR(A1),MONTH(A1)+1,1)-1)

Obviously, A1 has to have a date in it.

Works like a charm:

 Update, much, much later: Looks like LibreOffice has a DAYSINMONTH function.

Posted in ArticleTagged Excel, LibreOffice, Microsoft Office, OpenOffice

Related Stories

  • February 8, 2025 · Article

    Inkscape: “Document Properties” Window Not Showing Up

    Inkscape sometimes opens the “Documents Properties” window outside the visible area of the desktop. This is how you get it back.

  • December 30, 2023 · Article

    Synology Drive Client does not connect on Apple MacOS

    Synology Drive Client on MacOS refused to connect. Deleting the appropriate logfiles helped.

  • September 13, 2023 · Article

    “The iTunes Store is temporarily unavailable. Please try again later” when trying to subscribe to Podcast

    Currently (September 2023), Apple’s iTunes store seems to have a bug where it’s impossible to subscribe to new podcasts. However, there is a workaround. Find your desired podcast on the iTunes store. Click the “get” button, on the right side of the episode list, for any episode of the podcast. Switch to your library. The […]

Previous story Cube Root in OpenOffice Next story Postfix error – fatal: parameter “smtpd_recipient_restrictions”

20 Comments

  1. Robert says:
    August 2, 2017 at 10:40 pm

    thank you.:)

    Reply
  2. linto francis says:
    August 2, 2017 at 10:40 pm

    how do we get for previous month is there
    any formula for that

    Reply
  3. Balaji V S says:
    August 2, 2017 at 10:41 pm

    @Nishant ..did u get the solution..pls post,if yes

    Reply
  4. Wale Oye says:
    August 2, 2017 at 10:41 pm

    Thanks the formula works

    Reply
  5. Nishant Kumar Verma says:
    August 2, 2017 at 10:41 pm

    If possible I want to get result by giving name of month like “January”, “February” etc. instead of given date in cell A1. Is it possible? if yes, anybody please help me soon @ nishantverma8391@gmail.com

    Reply
  6. Nilesh Shah says:
    August 2, 2017 at 10:41 pm

    Thanks A lot

    Reply
  7. rohan says:
    August 2, 2017 at 10:41 pm

    thank you michael..

    Reply
  8. Ganesh says:
    August 2, 2017 at 10:41 pm

    thanks a lot……perfect formula to get a number of days in a month…..

    Reply
  9. Radhaballav Nath says:
    August 2, 2017 at 10:41 pm

    Thanks a lot

    Reply
  10. Nils says:
    August 2, 2017 at 10:41 pm

    Hey Linto,

    There seems to be no "get previous month" function in OpenOffice (and I don't have MS Office installed right now), so I came up with this formula which seems to work:

    =DATE(YEAR(a1);MONTH(a1)-1;1)

    It gives you the first day of the previous month of a date in field a1. To get the length of that previous month, just use the same formulas from this post on the date you have thus obtained.

    Reply
  11. PINDER says:
    August 2, 2017 at 10:41 pm

    THANKS MICKY BRO

    Reply
  12. PINDER says:
    August 2, 2017 at 10:41 pm

    THANKSSSSSSSSSSSSSSSSSSSSS

    Reply
  13. Nils says:
    August 2, 2017 at 10:41 pm

    Saiful, that's simply a matter of assigning the cell a custom date format, I'd say.

    Reply
  14. Saiful says:
    August 2, 2017 at 10:41 pm

    I want to get result by giving name of month like "January", "February" etc. instead of given date in cell B3. Is it possible? if yes, anybody please help me soon. Thanks

    Reply
  15. Michael. says:
    August 2, 2017 at 10:41 pm

    Awesome, one click answer, thanks.
    Now, can we calculate just the weekdays in a month with a similar method?

    Reply
  16. Vicky says:
    August 2, 2017 at 10:41 pm

    Thanks Mr. Nils & Mr.Micky

    Reply
  17. pan kaou says:
    August 2, 2017 at 10:41 pm

    Thanks Micky!!!!

    Reply
  18. Nils says:
    August 2, 2017 at 10:41 pm

    Thanks Micky!

    EOMONTH may not always be available it seems: http://office.microsoft.com/en-001/excel-help/eomonth-HP005209076.aspx – so if anybody can't use Micky's cool shorter version, the original formula should still do the trick 🙂

    Reply
  19. Michael (Micky) Avidan says:
    August 2, 2017 at 10:41 pm

    No need or such a "long" formula.

    In B2 type: =DAY(EOMONTH(B3,0))

    Michael Avidan
    “Microsoft®” MVP – Excel
    ISRAEL

    Reply
  20. vilva says:
    August 2, 2017 at 10:41 pm

    Really excellent. Thanks.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Inkscape: “Document Properties” Window Not Showing Up
  • Synology Drive Client does not connect on Apple MacOS
  • “The iTunes Store is temporarily unavailable. Please try again later” when trying to subscribe to Podcast
  • “Access Denied” Errors with TortoiseSVN on Samba
  • Keyboard and Mouse Microstutters with a Dell Latitude Notebook

Recent Comments

  1. Bart on Gigabyte OSD_Sidekick: “Please check if your USB cable is connected”
  2. Jason on Sony Vegas and Sony Movie Studio: No Audio Tracks In mp4 video filefound
  3. DaReclama on OpenVPN: IP packet with unknown IP version seen
  4. vilva on Excel Formula to get Number of Days in a Month
  5. Michael (Micky) Avidan on Excel Formula to get Number of Days in a Month

Archives

  • February 2025
  • December 2023
  • September 2023
  • July 2022
  • June 2022
  • April 2022
  • November 2021
  • March 2021
  • January 2021
  • August 2020
  • July 2020
  • May 2020
  • January 2020
  • May 2019
  • November 2018
  • July 2018
  • January 2018
  • August 2017
  • January 2017
  • September 2016
  • July 2016
  • October 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • June 2014
  • April 2014
  • February 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • July 2013
  • June 2013
  • April 2013
  • February 2013
  • October 2012
  • August 2012
  • March 2012
  • January 2012
  • October 2011
  • September 2011
  • August 2011
  • June 2011
  • July 2007

Categories

  • Article

© 2026 The Geek Worker. Proudly powered by WordPress.