Determine if a datetime in one model is within a datetime range of any row in another model

Matt SonesMatt Sones Member ✭✭
edited March 2019 in Questions
I have one model (A) with 20 or 30 rows, which includes a Datetime field.

I have another model (B) with ~ 0 to 10 rows which include Start and End datetime fields.

I want to exclude rows from Model A  where Datetime is between Start and End of any single row in Model B.

Anyone have a good idea on how to set up model conditions to do this?

Comments

  • Matt SonesMatt Sones Member ✭✭
    edited February 2018
    I decided to just brute force this with javascript since the community was silent. If anyone has an idea on how to do this declaratively, I'm love to hear it!
  • Rob HatchRob Hatch Skuad, Sonar ✭✭
    edited February 2018
    Can you turn model B into an aggregate that MIN's start and MAX's end?  Then you'd have 1 record to compare the records in model A against. 
  • Matt SonesMatt Sones Member ✭✭
    edited February 2018
    Thanks, Rob.

    Unfortunately, no )if I'm understanding correctly). If row 1 of model B covers last week and row 2 covers next week, I still want dates from model A in this week to show up.

    If I had just the min start and max end, that would include this week, correct?
Sign In or Register to comment.