October 15, 201510 yr Hi. I am looking for a function that allows me to determine if two date ranges overlap. Within a function I can check if a single date sits within a range of an upper and lower date (see below). It would be used to check hospital attendance for any given client over a reporting period. e.g. Client X was in a hospital bed from 30/4/2014 to 15/7/2015, and we want to see if this client was in situ during June 2015, so the function would be checking for a boolean result of two date ranges overlapping 30/4/2015...15/7/2015. Let ( [ LowerDate = DateCheck + LowerLimit ; HigherDate = DateCheck + HigherLimit ] ; If ( DateCheck ≥ LowerDate and DateCheck < HigherDate ; 1 ; 0 ) ) Does anybody know how I could modify this function please to input a range of dates rather than just a single date, perhaps using a loop or something else tricky? Any help would be appreciated. Greg
October 15, 201510 yr Two ranges overlap when: StartRangeA ≤ EndRangeB and StartRangeB ≤ EndRangeA Note:A Boolean expression already returns either 0 (False) or 1 (True). Your: If ( DateCheck ≥ LowerDate and DateCheck < HigherDate ; 1 ; 0 ) ) is a roundabout way of writing: DateCheck ≥ LowerDate and DateCheck < HigherDate I also didn't understand the meaning of your: LowerDate = DateCheck + LowerLimit What exactly is LowerLimit? If you want to check if a given date is within a given range, all you have to do is test for: StartRange ≤ GivenDate and GivenDate ≤ EndRange
Create an account or sign in to comment