is date within any date range in a dynamic array of date ranges
is date within any date range in a dynamic array of date ranges
(OP)
Hi,
I have a string containing multiple date ranges separated by <br> (number of date ranges varies for 1 to ?)
I need to evaluate if a specific date is within any of the date ranges and return true if the date is in any date ranges.
string ex. Jan 1 2020-Apr 2 2020<br>Nov 3 2021-Dec 2 2022<br>
so i have startdate + "-" + enddate<br> making up the date ranges the date ranges do not overlap.
The end result is a formula i can use to select records for a crystal report where formula is not true ( i dont want the record if the specific date is in any of the date ranges.
Thanks for any help.
I have a string containing multiple date ranges separated by <br> (number of date ranges varies for 1 to ?)
I need to evaluate if a specific date is within any of the date ranges and return true if the date is in any date ranges.
string ex. Jan 1 2020-Apr 2 2020<br>Nov 3 2021-Dec 2 2022<br>
so i have startdate + "-" + enddate<br> making up the date ranges the date ranges do not overlap.
The end result is a formula i can use to select records for a crystal report where formula is not true ( i dont want the record if the specific date is in any of the date ranges.
Thanks for any help.
RE: is date within any date range in a dynamic array of date ranges
local stringvar ranges :="Jan 1 2020-Apr 2 2020<br>Nov 3 2021-Dec 2 2022";
local numbervar result:=-1;
local datevar checkdt := date("Jan 4 2020");
local datevar startdt ;
local datevar enddt;
stringvar array dates := split(ranges,"<br>");
Numbervar i;
for i := 1 to Ubound(dates) do (
startdt:=date(Mid(dates[i], 1, inStr(dates[i], "-")-1));
enddt:=date(MID(dates[i],INSTR(dates[i], "-")+1));
If checkdt in startdt to enddt then
result:=0;
exit for
);
result