If formula to obtain current month and year

LambertyE

New Member
Joined
Nov 19, 2020
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hello Excel Fam,

I am trying to get around this formula.

Idea:
If a cell is not empty then the expected result is the current month and year.

Example:
When there is a date (or not empty cell) in column B then results should be current month and year column E. As shown below in red.

I have tried the following formula among others:
=IF(B2<>"","mm/yy")
=IF(C2<>"",MONTH(YEAR(TODAY())))

But the results I'm getting are 1/12 & 1/7, not even close to the correct results. Can someone shed some light?

Thanks in advance!

ABCDE
Paid7/31/20209/19/2020Yes8/20
Paid8/31/202010/20/2020Yes9/20
Paid9/30/202011/19/2020Yes10/20
Pending10/30/2020Yes11/20
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
What you're asking for will be
Excel Formula:
=IF(B2<>"",TEXT(TODAY(),"mm/yy"),"")
Although I should point out that any formula using TODAY() for the current date will show the current date when you're viewing the sheet, not the current date when the data was entered.
If you want to lock the date in place then you will need to use either vba or circular references.
 
Upvote 0
What you're asking for will be
Excel Formula:
=IF(B2<>"",TEXT(TODAY(),"mm/yy"),"")
Although I should point out that any formula using TODAY() for the current date will show the current date when you're viewing the sheet, not the current date when the data was entered.
If you want to lock the date in place then you will need to use either vba or circular references.
Thank you for the quick response!

Does that mean that every time the spreadsheet is viewed the date will change? If yes, how can be overcome? what is needed is the month and year the invoice belongs to. Any ideas as to how we can get around that. Your input is greatly appreciated!

Thanks again!
 
Upvote 0
Based on what I see in your examples (column E is the month following the date in column B), try
Excel Formula:
=IF(B2="","",EOMONTH(B2,1))
with a custom format of mm/yy
 
Upvote 0
Based on what I see in your examples (column E is the month following the date in column B), try
Excel Formula:
=IF(B2="","",EOMONTH(B2,1))
with a custom format of mm/yy
Thank you!

So sorry to bother, we are getting closer though, the results with this formula are coming with month and day (i.e.: 1/31, 2/29 ) but what I need is month and year (i.e.: 1/20, 2/20, etc).
 
Upvote 0
That would be the wrong format applied. The formula produces the last day of the month, the format dictates which part is displayed. mm/yy shows month and year (may be different if your system settings are in a language other than english).
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top