Countif using datedif

chongki

New Member
Joined
Oct 24, 2023
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hello, I have the following data on a sheet:

Book2
AB
1ItemsExpiry
2Item 111/24/2023
3Item 201/02/2024
4Item 302/01/2024
5Item 411/01/2023
6Item 510/29/2023
7Item 612/25/2023
8Item 707/25/2023
9
10# expiring in <1 month:
Sheet1


I need to count the items that are expiring in 1 month or less. The answer should be 3 and I try countif with datedif, but it's not working. Being a super beginner, the formula i used was =COUNTIF(B2:B8,DATEDIF(TODAY(),B2:B8,"M")<1), but it spills and outputs 0 all the way down. If I put the operator @ like so: =COUNTIF(B2:B8,DATEDIF(TODAY(),@B2:B8,"M")<1), it doesn't spill but just outputs 0.
Any help will be very very appreciated.

Thank you!
 

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.
try
=COUNTIFS(B2:B8,"<="&DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY())))
I make 4 as i have included an =
and 24/11/23 is the same date as today - if you do want to include that , then remove the = "<="& becomes "<"&

Book2
ABCDEF
1ItemsExpiry
2Item 111/24/23411/24/23TRUE
3Item 21/2/2411/24/23FALSE
4Item 32/1/2411/24/23FALSE
5Item 411/1/2311/24/23TRUE
6Item 510/29/2311/24/23TRUE
7Item 612/25/2311/24/23FALSE
8Item 77/25/2311/24/23TRUE
Sheet1
Cell Formulas
RangeFormula
C2C2=COUNTIFS(B2:B8,"<="&DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY())))
E2:E8E2=DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY()))
F2:F8F2=B2<=E2
 
Upvote 1
Solution
try
=COUNTIFS(B2:B8,"<="&DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY())))
I make 4 as i have included an =
and 24/11/23 is the same date as today - if you do want to include that , then remove the = "<="& becomes "<"&

Book2
ABCDEF
1ItemsExpiry
2Item 111/24/23411/24/23TRUE
3Item 21/2/2411/24/23FALSE
4Item 32/1/2411/24/23FALSE
5Item 411/1/2311/24/23TRUE
6Item 510/29/2311/24/23TRUE
7Item 612/25/2311/24/23FALSE
8Item 77/25/2311/24/23TRUE
Sheet1
Cell Formulas
RangeFormula
C2C2=COUNTIFS(B2:B8,"<="&DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY())))
E2:E8E2=DATE(YEAR(TODAY()),MONTH(TODAY())+1,DAY(TODAY()))
F2:F8F2=B2<=E2
Thank you so so much! Works perfect!
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,021
Members
449,092
Latest member
ikke

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