DataFaucet ORM

Timespan Filter

The timespan filter allows you to find records which represent a span of time overlapping two dates you specify. For example, you may have a week-long training seminar and want to find any other similar seminars in your database which overlap the same week (but may start or end on different days).

By reversing the overlap argument you can find records representing spans of time not overlapping the indicated period. So for example if you have events during your week-long seminar and you want to provide users with a method of scheduling their events, you can show them all events not overlapping the time of a selected event (and therefore available to them) by setting the overlap argument to false, effectively reversing the timespan filter.

The timespan filter has these properties:

PropertyDefaultDescription
startcolumnn/arequired - a database column containing start dates
endcolumnn/arequired - a database column containing end dates
starttimen/arequired - start of the span of time to overlap
endtimen/arequired - end of the span of time to overlap
overlaptrueboolean - set to false to return records that don't overlap the specified time span

Example:

<cfscript>
  // get the datasource
  ds = request.DataFaucet.getDatasource(); 
  // create a select statement 
  stmt = ds.getSelect("*","tblSeminar sem"); 
  
  // find seminars overlapping the first week of january 
  stmt.timespanfilter("startdate","enddate","1/1/2008","1/7/2008"); 
  
  // get the results 
  query = stmt.execute(); 
</cfscript>