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

  • 1
  • Question
  • Updated 9 months ago
  • In Progress
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?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 9 months ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
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!
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
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. 
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
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?