Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Pull Date-Effective Records that Intersect A Given Range (See related posts)

Basics of how to pull records that intersect a date range from a temporal (aka date-effective) database.

-- @rangeStart is the start of the date range of interest
-- @rangeEnd is the end of the date range of interest
-- If you use null to signify infinity, then use the commented line instead of the one above it.
select *
from DateEffectiveTable
where StartDate < @rangeEnd
  and EndDate >= @rangeStart
  -- and coalesce(endDate, '9999-12-31') >= @rangeStart

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts