TravisJBennett
New Member
- Joined
- Dec 28, 2012
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
- Mobile
- Web
I've made a (really neat, and tough to write!) formula that evaluates a single date against a single cell's value, where that cell contains multiple date ranges, and then indicate whether or not the date is within any of the listed multiple date ranges.
The multiple date ranges are formatted in a familiar manner: Like when printing multiple select pages from whatever app, e.g. 1-2, 5-8, 15-34
For this example, my date format is M/D/YYYY. We'll disregard other/international date representations for the moment (honestly, I use them all).
Example Date Ranges (crammed as text into a single cell): 9/1/2022-9/8/2022,9/10/2022-9/10/2022,9/12/2022-9/25/2022,10/1/2022-10/1/2022
Input: 9/5/2022
Output: TRUE
That all works great! I love it, and despite the complexity of jamming all these dates into one cell, is exactly what I need (for phase 1).
HELP!
So how can I adapt a copy of my formula in $C$12, so that for Example Date Ranges, it can accept a range instead of a single cell, and operate one cell at a time to determine TRUE vs. FALSE. then output a SPILL range of TRUEs and FALSEs ?
The multiple date ranges are formatted in a familiar manner: Like when printing multiple select pages from whatever app, e.g. 1-2, 5-8, 15-34
For this example, my date format is M/D/YYYY. We'll disregard other/international date representations for the moment (honestly, I use them all).
Example Date Ranges (crammed as text into a single cell): 9/1/2022-9/8/2022,9/10/2022-9/10/2022,9/12/2022-9/25/2022,10/1/2022-10/1/2022
Input: 9/5/2022
Output: TRUE
That all works great! I love it, and despite the complexity of jamming all these dates into one cell, is exactly what I need (for phase 1).
HELP!
So how can I adapt a copy of my formula in $C$12, so that for Example Date Ranges, it can accept a range instead of a single cell, and operate one cell at a time to determine TRUE vs. FALSE. then output a SPILL range of TRUEs and FALSEs ?
DateRangeDemo.xlsx | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | ||||||||||||
2 | Given: A comma-separated list of multiple dates and date-ranges (like one might enter when printing a custom page range...) | |||||||||||
3 | Three Examples (we'll start on the right with just the top cell…) | Processing a single cell's dates and date ranges… | ||||||||||
4 | 9/1/2022-9/8/2022,9/10/2022-9/10/2022,9/12/2022-9/25/2022,10/1/2022-10/1/2022 | } -----------------> | 9/1/2022-9/8/2022 | aka | 44805 | 44812 | ||||||
5 | 9/30/2022-10/4/2022,10/8/2022-10/12/2022,10/20/2022-10/31/2022 | <-- used below | 9/10/2022-9/10/2022 | 44814 | 44814 | |||||||
6 | 10/25/2022-11/02/2022,11/7/2022-11/15/2022,11/18/2022 | <-- used below | 9/12/2022-9/25/2022 | 44816 | 44829 | |||||||
7 | 10/1/2022-10/1/2022 | 44835 | 44835 | |||||||||
8 | ||||||||||||
9 | Checking a value against a single cell containing CSV multiple ranges and/or values, in this case dates and having strict midnight values (integer dates). | |||||||||||
10 | Checking this date: | 44814 | (aka, 9/10/2022) | |||||||||
11 | ||||||||||||
12 | In Range? | TRUE | ||||||||||
13 | Out of Range? | FALSE | ||||||||||
14 | ||||||||||||
15 | Everything here and above works great! | |||||||||||
16 | My question: How do I adapt my "In Range?" formula, to check the one highlighted date against each cell with $A$4:$A$6, and get results back in a nice spill array (e.g. of 3Rx1C for this short example)? | |||||||||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C4:C7 | C4 | =CONCATENATE(FILTERXML("<t><s>" & SUBSTITUTE($A$4, ",", "</s><s>") & "</s></t>", "//s")) |
E4:F7 | E4 | =CHOOSE({1,2}, CONCATENATE(FILTERXML("<t><b>" & SUBSTITUTE(SUBSTITUTE($A$4, ",", "</e><b>"),"-","</b><e>") & "</e></t>", "//b")), CONCATENATE(FILTERXML("<t><b>" & SUBSTITUTE(SUBSTITUTE($A$4, ",", "</e><b>"),"-","</b><e>") & "</e></t>", "//e")) ) |
E10 | E10 | ="(aka, "&TEXT(C10,"M/D/YYYY")&")" |
C12 | C12 | =LET( UsingDate,$C$10, DateSpans,$A$4, SingleDatesExpanded,TEXTJOIN(",",FALSE,SUBSTITUTE( IF(LEN(CONCATENATE(FILTERXML("<t><s>" & SUBSTITUTE(DateSpans, ",", "$</s><s>") & "$</s></t>", "//s")))<=11, CONCATENATE(FILTERXML("<t><s>" & SUBSTITUTE(DateSpans, ",", "$</s><s>") & "$</s></t>", "//s"))&"-"&CONCATENATE(FILTERXML("<t><s>" & SUBSTITUTE(DateSpans, ",", "$</s><s>") & "$</s></t>", "//s")), (CONCATENATE(FILTERXML("<t><s>" & SUBSTITUTE(DateSpans, ",", "$</s><s>") & "$</s></t>", "//s")))), "$","")), DateArray, CHOOSE({1,2}, CONCATENATE(FILTERXML("<t><b>" & SUBSTITUTE(SUBSTITUTE(SingleDatesExpanded, ",", "</e><b>"),"-","</b><e>") & "</e></t>", "//b")), CONCATENATE(FILTERXML("<t><b>" & SUBSTITUTE(SUBSTITUTE(SingleDatesExpanded, ",", "</e><b>"),"-","</b><e>") & "</e></t>", "//e"))), SUMPRODUCT(--(UsingDate>=VALUE(INDEX(DateArray,,1))),--(UsingDate<=VALUE(INDEX(DateArray,,2)))) )=1 |
C13 | C13 | =NOT(C12) |
Dynamic array formulas. |