Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Juggernaut

Date range overlap check

Featured Replies

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

 

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.