Hello David !
I'm trying to create a Drop Record RegExp filter rule what drops records older than current date.
Example
In datafeed ENDDATE field is like
2018-12-25
Today is
2019-01-19
So we need to drop such the records...
I suppose RegExp matching current date for format 2019-01-19 is something like
/$year$-$0month$-$0day$/
but what next ?
Thank you very much for any hint !
David, thanks a lot !
Your solution works !
Like your many other ones :)
Have a nice and prosperous 2019 !
Serge
Hi,
It would be easiest to create a standalone filter for this purpose - Drop Record If Expired - to give this a go, add the following to includes/filter.php:
/*************************************************/
/* dropRecordIfExpired */
/*************************************************/
$filter_names["dropRecordIfExpired"] = "Drop Record If Expired";
function filter_dropRecordIfExpiredConfigure($filter_data)
{
print "<p>There are no additional configuration parameters for this filter.</p>";
}
function filter_dropRecordIfExpiredValidate($filter_data)
{
}
function filter_dropRecordIfExpiredExec($filter_data,$text)
{
global $filter_dropRecordFlag;
global $filter_dropRecordIfExpiredTime;
if (!isset($filter_dropRecordIfExpiredTime))
{
$filter_dropRecordIfExpiredTime = time();
}
$expired = strtotime($text." 23:59:59");
$filter_dropRecordFlag = ($expired < $filter_dropRecordIfExpiredTime);
return $text;
}
Including the time in this line:
$expired = strtotime($text." 23:59:59");
...ensures that an ENDDATE of today would be kept - if you wanted to drop ENDDATE values of today then REPLACE this with just:
$expired = strtotime($text);
Cheers,
David.
--
PriceTapestry.com