Jump to content
Server Maintenance This Week. ×

Date range overlap check


This topic is 3118 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

 

Link to comment
Share on other sites

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

 

 

  • Like 1
Link to comment
Share on other sites

This topic is 3118 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.