A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
MIN and MAX do not return an array of values, but a single value. You want to sum an array of values.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
hi,
i would like to create a formula where i calculate the total days between 2 dates per row and provide one total number. below the formula i use
=SUMPRODUCT(MAX(0; MIN(IF(($C$2:$C$7 > DATE(2024; 3; 31)) + ISBLANK($C$2:$C$7); DATE(2024; 3; 31); IF(($C$2:$C$7 < DATE(2024; 3; 1));0;$C$2:$C$7)); DATE(2024; 3; 31)) - MAX(IF($B$2:$B$7 < DATE(2024; 3; 1); DATE(2024; 3; 1);IF($B$2:$B$7 > DATE(2024; 3; 31);0; $B$2:$B$7)); DATE(2024; 3; 1)) + 1))
column B is the "start date" and column C the "end date" and i want the total days in March. should the end date in column C be blank, it needs to use the end of march as end date
below is the data im using
| Start date | End Date |
|---|---|
| 01/02/2024 | 28/02/2024 |
| 07/02/2024 | |
| 15/02/2024 | 17/03/2024 |
| 01/03/2024 | 06/03/2024 |
| 12/03/2024 | |
| 05/04/2024 | 07/05/2024 |
appreciate the support here
gr
micky
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
MIN and MAX do not return an array of values, but a single value. You want to sum an array of values.
this worked perfectly! thanks
i just wonder why my formula didnt work
If you have Excel 2019 or older:
=SUM(IF(IF((C2:C7>DATE(2024, 3, 31))+(C2:C7=""), DATE(2024, 3, 31), C2:C7)-IF(B2:B7<DATE(2024, 3,1), DATE(2024, 3, 1), B2:B7)<0, 0, IF((C2:C7>DATE(2024, 3, 31))+(C2:C7=""), DATE(2024, 3, 31), C2:C7)-IF(B2:B7<DATE(2024, 3,1), DATE(2024, 3, 1), B2:B7)))
Confirm the formula by pressing Ctrl+Shift+Enter.
If you have a newer version:
=LET(first, DATE(2024, 3, 1), start, IF(B2:B7<first, first, B2:B7), last, DATE(2024, 3, 31), end, IF((C2:C7>last)+(C2:C7=""), last, C2:C7), difference, end-start, SUM(IF(difference<0, 0, difference)))
You don't need Ctrl+Shift+Enter for this.
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more