DataFaucet ORM

Date Filter

A date filter is a convenient way of filtering content between two dates. A date filter is specified with one column name and two content values - a start date and an end date.

Example:

<cfscript>
  // get the datasource
  ds = request.DataFaucet.getDatasource(); 
  // create a select statement 
  stmt = ds.getSelect("*","tblEmployee emp"); 
  
  // filter by employee hire date 
  stmt.dateFilter("hiredate",form.startdate,form.enddate);
  
  // get the results 
  query = stmt.execute(); 
</cfscript>

The 2nd content value of a date filter can also be numeric indicating a specific number of days. For example to filter new hires within a particular week, you might use:

<cfset stmt.dateFilter("hiredate","1/1/2008",7) />

If you omit the 2nd content argument, it defaults to 1-day, so to get new hires on a specific day, from 12-midnight to midnight of the following day, you could simply use this:

<cfset stmt.dateFilter("hiredate","1/1/2008") />