IFS function with dates

BigGee

New Member
Joined
Sep 8, 2020
Messages
9
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I am trying to interrogate a spreadsheet to return a month number if a date falls between the first and start of a month. I understand this would be easy using MONTH function but as my data covers several years I want to allocate a month and year number.

I have the IF function for a single entry which works correctly
=IF(AND(B4>=DATEVALUE("01/05/2020"),B4<=DATEVALUE("31/05/2020")),"5/20","NO")

but when I try to convert to IF to an IFS function by adding in other months then I cannot get it to work.

=IFS(AND(B5>=DATEVALUE("01/05/2020"),B5<=DATEVALUE("31/05/2020")),"5/20",B5>=DATEVALUE("01/04/2020"),B5<=DATEVALUE("30/04/2020"),"4/20",B5>=DATEVALUE("01/03/2020"),B5<=DATEVALUE("31/03/2020"),"3/20")
returns me a correct response for May, a TRUE value for an April date and #VALUE for March

Could anyone either
1. tell me where I am going wrong, or
2. show me an easier way?

Thanks in advance
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I think you are missing the "AND" in the formula where you are trying to check the second date range.
 
Upvote 0
I think you are missing the "AND" in the formula where you are trying to check the second date range.
Adding in an AND function as below
=IFS(AND(B6>=DATEVALUE("01/05/2020"),B6<=DATEVALUE("31/05/2020")),"5/20",AND(B6>=DATEVALUE("01/04/2020"),B6<=DATEVALUE("30/04/2020"),"4/20"),AND(B6>=DATEVALUE("01/03/2020"),B6<=DATEVALUE("31/03/2020"),"3/20"))
May works but now April and March also return a #VALUE
 
Upvote 0
Why not just use
=MONTH(B6)&"/20"
 
Upvote 0
Solution
Since data is spanning several years:
=MONTH(B6) & "/" & YEAR(B6)
 
Upvote 0
You are welcome!
I only added to Fluff's insight.
 
Upvote 0
Or TEXT(B6,"m/yy")
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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