Filtering on Date fields

October 18th, 2014

You may have fields in your form that contain dates. In the database, these are saved simply as text. To filter on dates, use the short code Filter Function capability to apply the PHP strtotime (string-to-time) function in your filter.

(Note: if filtering on special field submit_time, see Filtering on submit_time)

Here is an example from an actual user:

Question:
After ordering on date I also want to filter on date (not submission-date). Is it possible to filter on dates for example
(1) The last 4 weeks (startpoint = today)
(2) Today and coming 7 days

Solution:
Given a “Date Form” with field “date” with values like “7/17/2014

(1) [cfdb-table form="Date Form" filter="strtotime(date)>=strtotime('4 weeks ago')"]

(2) [cfdb-table form="Date Form" filter="strtotime(date)>=strtotime('today')&&strtotime(date)<=strtotime('+7 days')"]

 

Learn more about how to express time comparisons on the Filtering on submit_time page

Comments are closed.  Go To Support Forum