Home > Blockchain >  Formating dates with =text(month(today()), "MMM")
Formating dates with =text(month(today()), "MMM")

Time:12-21

I... don't know how to process this. Can someone explain what's happening to me?

Today's 20 December 2021. When I put the below formula into Google Sheets, I get "Jan"

=text(month(today()), "MMM")

https://docs.google.com/spreadsheets/d/1uLC0Q0dgChEbfNXjXEketyc64tsurz4vQ9o1QFO87NY/edit?usp=sharing

CodePudding user response:

By including "MMM" in the =text() function you're already telling it that you want a month, so there is no need for the extra month().

Removing it would leave the formula as =TEXT(TODAY(), "MMM"), giving the correct result.

CodePudding user response:

The other responses were super helpful, and it helped me figure out why it was happening.

Google Sheets, by default, processes dates as days since January 1, 1900 (so if you input a "1" and then format it as a date, you'll get January 1, 1990).

In the formula I mentioned above,

=text(month(today()), "MMM")

... the month(today()) section of the code outputs "12". When the "text" formula coerces that value into a month-value, it expects a full date. As a consequence, =text(month(today()), "MMM") asks for the month ("MMM") of date-value "12" (i.e. January 11, 1990).

That's why =text(month(today()), "MMM") outputs "Jan."

To fix the code, as others have said, you need to remove the "month()" section of the formula, therefore,

=text(today()), "MMM")

  • Related