Date Range validation

Hi ,

I have a list of dictionaries with date ranges(refer below screenshot)

i need validation that if i give a date and if the given date is overlapped with any of the dates(start and end date) i should get a validation. 

for example;

start date : 05/10/2023

end date : 05/15/2023

i'm comapring the given date in this date range for each dictionary for that it is working fine but if i select date between 05/09/2023 and 05/16/2023 i should get validation that is not working,and there are many dictionaries like this.  Cany anyone help me how to do this?

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Lead Developer
    in reply to Druva

    This is a code snippet that checks one range against other ranges and returns true if there is an overlap.

    a!localVariables(
      local!ranges: {
        a!map(start: date(2023, 1, 10), end: date(2023, 1, 20)),
        a!map(start: date(2023, 2, 12), end: date(2023, 3, 1)),
      },
      local!new: a!map(start: date(2023, 1, 15), end: date(2023, 2, 1)),
      a!forEach(
        items: local!ranges,
        expression: and(
          local!new.start <= fv!item.end,
          local!new.end >= fv!item.start
        )
      )
    )

Children
No Data