Home > Blockchain >  How can I calculate today's date ONLY if today is less than or equal to the last day of the cur
How can I calculate today's date ONLY if today is less than or equal to the last day of the cur

Time:10-18

I would like to express the following expression in Google Sheets:

IF today's date is less than or equal to the last day of the current month (in this case October 2021), THEN output today's date, OTHERWISE output the last day of the month (i.e. October 31, 2021)

I've tried a few different ways but nothing seems to work. Below is my latest attempt, but I get an #ERROR.

=IF(TODAY(<=2021,10,31),TODAY(),DATE(2021,10,31))

Thank you in advance for your help.

CodePudding user response:

You need EOMONTH() function. Try below formula-

=IF(TODAY()<=EOMONTH(TODAY(),0),TODAY(),EOMONTH(TODAY(),0))

enter image description here

CodePudding user response:

Just use =TODAY(). if you are interested in current month.

If you need today's date, but not further then the last day of October, use:

=MIN(TODAY(), DATE(2021, 10, 31))

CodePudding user response:

Are you allowed to do this?

If not, @Harun24GR answer will do it for you.

enter image description here

  • Related