Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

is date within any date range in a dynamic array of date ranges

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

Figured this out using hardcoded values as a test.
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
exit for


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close