removeDate not working

15 posts by 3 authors in: Forums > CMS Builder
Last Post: August 30, 2019   (RSS)

By Deborah - August 29, 2019

The removeDate field isn't functioning as I expect it to or I'm not understanding how to use it correctly.

My understanding is that it's not necessary to use a where clause for 'removeDate' - the mySQL records list will auto-magically omit past-date records.

removeDate recorded in database is:
2019-08-20 00:00:00

Neither of the following examples work - all records are displayed.

TEST #1 - no where clause

// load records from 'featured_events'
list($featured_eventsRecords, $featured_eventsMetaData) = getRecords(array(
'tableName' => 'featured_events',
'limit' => '4',
'allowSearch' => false,
));

TEST #2 - with where clause

//Get the current date in SQL date format
$date = date('Y-m-d 00-00-00');

// load records from 'featured_events'
list($featured_eventsRecords, $featured_eventsMetaData) = getRecords(array(
'tableName' => 'featured_events',
'limit' => '4',
'where' => '(NOW() < removeDate)',
'allowSearch' => false,
));

----------

Probably overlooking the obvious? Any help would be appreciated!

~ Deborah

Hey Deborah,

Have you looked at this for possible syntax ideas?

https://www.interactivetools.com/forum/forum-posts.php?postNum=2240342#post2240342

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

By Deborah - August 29, 2019

Yes, Jerry, I did see that post - thanks. Some good-to-know code there.

My need for this project is simply that I don't want to display any records after the 'removeDate'.

The CMSB documentation page defines 'removeDate' as:
"Record won't be displayed on website after this date. This allows users to have content automatically "expire" from website after a certain date and time."

Hmm.

By gkornbluth - August 29, 2019 - edited: August 29, 2019

Hi Deborah,

I just tested the removeDate feature on a record in a multi-record editor3.50 installation (it's the latest I have) and it worked for me

When the remove date is set to before today, the 'never remove' checkbox is not checked, and that record is saved, that record's information disappears from my front end list page after I refresh the list page.

Are you running the same or a later CMSB version? Could your cache be keeping an earlier version of the page?

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

By daniel - August 29, 2019

Hi Deborah,

I can confirm that you're not missing something obvious; it should be working as you have it, so there must be something else at play. Along with what Jerry has suggested, something you can try is switching the "<" for ">" in your where statement above so you get something like this:

// load records from 'featured_events'
list($featured_eventsRecords, $featured_eventsMetaData) = getRecords(array(
'tableName' => 'featured_events',
'limit' => '4',
'where' => '(NOW() > removeDate)',
'allowSearch' => false,
));

If the first query returns all records, then this should theoretically return 0 records. Whether or not this happens in your case could help us narrow down the issue.

Thanks,

Daniel
Technical Lead
interactivetools.com

Hi Daniel,

I didn't need a where clause on my list page, it just worked as it was supposed to.

My load records code is similar but without the limit and the where

Does needing a where have anything to do with the

'limit' => '4',

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

By Deborah - August 29, 2019

Jerry - thanks for your thoughts.

I'm not using a "never remove" checkbox.

This install's CMSB version is 3.51.

Cache cleared (good idea), but no change.

Thanks again!

By Deborah - August 29, 2019

Daniel,

Just tested with the following code:

// featured_events list
list($featured_eventsRecords, $featured_eventsMetaData) = getRecords(array(
'tableName' => 'featured_events',
'limit' => '4',
'where' => ' (NOW() > removeDate) ',
'allowSearch' => false,
'loadCreatedBy' => false,
));

(realizing now I had used < instead of > for removeDate)

The above code does remove all records, even those with dates that shouldn't yet be removed, such as this record's date stored in the database:
2019-09-15 00:00:00

I seem to get "all or nothing". Shouldn't 'removeDate' take care of that filtering behind the scenes, without need of a 'where'?

~ Deborah

Hi Deborah,

That's been my experience, and my test confirmed it.

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