0

I'm trying to use a complex filter in my WSproxy retrieve method that gets values where their date is between two dates. I'm this currently:

var ThreeDaysAgoFilter = {
      LeftOperand:{
        Property: "UnsubscribeDate",
        SimpleOperator: "greaterThan",
        Value: threeDaysAgo
      },
      LogicalOperator: "AND",
      RightOperand:{
        Property: "UnsubscribeDate",
        SimpleOperator: "lessThan",
        Value: twoDaysAgo
      }
    };

But it's not working. I notice that there's a "between" operator https://www.ssjsdocs.xyz/reference/complex-filters.html but I can't find an example of it being used. I want to test it out but unsure of how the syntax should be.

For example, is the SimpleOperator: "Between" then what should go in the value? Both dates?

1 Answer 1

2

If you use the SimpleOperator "between", what you need is to put an array into the Value property.

E.g. I have this DE: enter image description here

And I want to filter out the records where its date value from 10/02/2023 to 10/06/2023. I would do something like this:

<script runat="server">
Platform.Load("Core","1.1.1");
var prox = new Script.Util.WSProxy();

var customerKey = "My DE customer key";
var cols = ["CustomerKey", "Name", "Date"];
var filter = {Property: "Date", SimpleOperator: "between", Value: ["2023-10-02", "2023-10-06"]}

var data = prox.retrieve("DataExtensionObject[" + customerKey + "]", cols, filter)
Write(Stringify(data.Results));

</script>

The output will be something like:

[
  {
    "Name": null,
    "Keys": null,
    "Type": "DataExtensionObject",
    "Properties": [
      {
        "Name": "CustomerKey",
        "Value": "3"
      },
      {
        "Name": "Name",
        "Value": "Jane"
      },
      {
        "Name": "Date",
        "Value": "10/4/2023 12:00:00 AM"
      }
    ],
"Client": null,
"PartnerKey": null,
.....
 }
]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .