Closed Thread
Results 1 to 11 of 11

=month() function returns value of 1 on blank cell

  1. #1
    Registered User
    Join Date
    03-28-2012
    Location
    Union City, CA
    MS-Off Ver
    Excel 2010
    Posts
    13

    =month() function returns value of 1 on blank cell

    I have two columns: one is for date and the other uses the =month() function to pull the number of the month. The spreadsheet will be filled out by other users so the date column is not yet populated. The =month() function is returning a value of 1 from a cell that is blank. How do I get the =month() cell to be blank or return a value of 0 until the date field is populated?

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: =month() function returns value of 1 on blank cell

    Try:

    =IF(A1="","",MONTH(A1))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: =month() function returns value of 1 on blank cell

    try this
    =IF(ISBLANK(A1),0,MONTH(A1))
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

  4. #4
    Registered User
    Join Date
    03-28-2012
    Location
    Union City, CA
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: =month() function returns value of 1 on blank cell

    Thank you very much.

  5. #5
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: =month() function returns value of 1 on blank cell

    You can also use TEXT function,

    =TEXT(A1,"m;;;")

    if A1 is Negative, zero, blank or text will show as blank.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: =month() function returns value of 1 on blank cell

    So you're aware of *why* it's returning 1 (January).. it's because dates in Excel are actually stored and processed as numbers starting with January 1, 1900. The number for that date is 1. Today, March 28, 2012, is number 40996, since it is the 40,996th day since "the beginning of time" (January 1, 1900).

    When you have a blank cell (or 0 in a cell) and test it using certain date functions, it will return - oddly - January 0, 1900. It's not a real date, of course, but Excel considers it to be in January.

  7. #7
    Registered User
    Join Date
    10-21-2019
    Location
    Lagos, Nigeria
    MS-Off Ver
    2016
    Posts
    1

    Re: =month() function returns value of 1 on blank cell

    Awesome. I won't have figured that out that easy. Thanks

    Quote Originally Posted by Haseeb A View Post
    You can also use TEXT function,

    =TEXT(A1,"m;;;")

    if A1 is Negative, zero, blank or text will show as blank.

  8. #8
    Registered User
    Join Date
    12-14-2019
    Location
    Pacific
    MS-Off Ver
    Office 365
    Posts
    2

    Re: =month() function returns value of 1 on blank cell

    Thanks so much, Haseeb - that worked like a charm!

    Can you please explain why the three trailing semicolons hide negative, zero, or blank text? Microsoft's TEXT function documentation does not provide any clues (sadly, I cannot post a link to it due to forum restrictions on new users).

    In any case, it's just what I was after to prevent "January 0, 1900" from appearing when evaluating a blank cell.

    Thank you again!
    Last edited by offbyone; 12-14-2019 at 03:49 AM. Reason: fix typo

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,453

    Re: =month() function returns value of 1 on blank cell

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

  10. #10
    Registered User
    Join Date
    12-14-2019
    Location
    Pacific
    MS-Off Ver
    Office 365
    Posts
    2

    Re: =month() function returns value of 1 on blank cell

    Quote Originally Posted by Pepe Le Mokko View Post
    Welcome to the forum.
    Thank you for your kind greeting! And thanks for your work in keeping this forum together.

    Quote Originally Posted by Pepe Le Mokko View Post
    whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.
    I'm sorry if my question wasn't clear; I am not adding anything unique, just asking why the three semicolon solution had worked; I couldn't find any reference to such a convention anywhere else.

  11. #11
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,421

    Re: =month() function returns value of 1 on blank cell

    You should still start a new thread - just make reference to this one. Your thread title can relate directly to the use of the three semi-colons. Please do as you have been asked. Thanks.
    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.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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