Date Filter through Code (Invalid Date Error)

Hey guys I’m having difficulty applying a value to a Date Filter field using code. I need to set it to ‘…DATE’, but I get an error saying “Invalid Date” if I do so. Here’s what my code looks like… gvtblCust.RESET; gvtblCust.GET("Sales Invoice Header".GETFILTER("Bill-to Customer No.")); EVALUATE(gvtblCust."Date Filter",COPYSTR("Sales Invoice Header".GETFILTER("Document Date"),1,8)); gvtblCust."Date Filter" := CALCDATE('-1D',gvtblCust."Date Filter"); EVALUATE(gvtblCust."Date Filter",'..' + FORMAT(gvtblCust."Date Filter")); gvtblCust.CALCFIELDS("Net Change (LCY)"); If you run the Customer table, click Flow Filters and type the above value into the Date Filter field, it works perfectly. Can anyone help me to accomplish this through code? Thanks Brad

Hi Brad, EVALUATE(gvtblCust."Date Filter",'..' + FORMAT(gvtblCust."Date Filter")); is where the problem is. Use SETFILTER in stead. I would also build some checks, to make sure that the filter on “Sales Invoice Header”.“Bill-to Customer No.” only includes one customer, or else the gvtblCust.GET will fail. Also You will have to check that the filter set on “Sales Invoice Header”.“Document Date” only includes 1 date. Say that the filter is set with an open start-date (…01/01/06), the filter you end up with is something like …01/01/ regards, Alexander

Thanks Alexander, it appears to be working now. This code is from a payment reconciliation Dataport that is only ever issued to one customer at a time and only for a whole month period (eg. 010405…300405), which I check for in an earlier section of code. Thanks for the concern though, it may have been something that I missed. :slight_smile: Regards Brad