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 geekworker

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
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

© 2026 The Geek Worker. Proudly powered by WordPress.