getRecords - Date Field Filter

4 posts by 3 authors in: Forums > CMS Builder
Last Post: January 29, 2013   (RSS)

Hello, All

I need to define a where clause in a getRecords function that will filter out a particular field. In this instance the field in question is a date field. I want getRecords to bypass all records in which a date has been submitted. In effect it needs to say:

where => ' date is empty ' 

Or some such thing!

:0)

Perch

I too just finished struggling with this problem except I needed all with no date where you need the opposite.

I found that this works but don't know if there is a better way:

'where'    => "ship_date != '0000-00-00 00:00:00'",  // filters out all with no date.

since date fields are stored padded with zeros and is not as a NULL

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

Cheers Ron. Works perfectly!

:0)

Perch

Hi Perch,

You might also give this plugin a try.  Dave created it a few years back.

it blanks out fields on input that are submitted with nothing but whitespace and field on output with zero'd out (blank) dates.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php