Hi,
I am trying to create an audience in AEP using API to get profiles that have a certain date attribute before or on a certain date attribute +30 days.
I am using this as the API body:;
-d '{
"name": "LatestCQdt lte LatestDD + 30",
"profileInstanceId": "AEPSegments",
"description": "Latest Cheque Redeem Date is before or on Most Recent Drop Date + 30 days",
"type": "SegmentDefinition",
"expression": {
"type": "PQL",
"format": "pql/text",
"value": "_myTenant.abnCalculatedAttributes.LastChequeRedeemedDate <=
_myTenant.abnCalculatedAttributes.Most_Recent_Drop_Date_DM + INTERVAL '\''30 days'\'' "
},
"schema": {
"name": "_xdm.context.profile"
}
}'
but it gives me this error:
{
"code": "400",
"message": "Error in parsing PQL expression \"_myTenant.abnCalculatedAttributes.LastChequeRedeemedDate <= _myTenant.abnCalculatedAttributes.Most_Recent_Drop_Date_DM + INTERVAL '30 days' \": line 1:130 token recognition error at: '''"
}
It is probably because of the wrong syntax for INTERVAL function, but I cannot find anywhere how to use this function and what is, in fact the syntax. I want to just add 30 days to the date.
Any suggestions?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi, I ultimately decided not to use the API audience for this case. The code provided by support was invalid, as there is no INTERVAL function in PQL syntax. We eventually identified the correct way to define the audience through the UI and proceeded with that approach.
@GabrielaNa1 As I know, AEP's PQL currently doesn't support standard SQL-style interval expressions. You may want to calculate prior and store the mostRecentDropDateDM + 30 days as a new field. Another option is to try using date_diff() for comparing days between two date attributes.
HI,
The INTERVAL syntax was suggested from Adobe support. I cannot find any reference on the Internat to INTERVAL in connection to PQL, or date_diff (the one you suggested) for that matter. Do you know where to find the complete reference for Adobe PQL, something that will give more details on this variant of SQL?
Hello @GabrielaNa1
I would recommend reviewing the following page for date formatting functions within the PQL syntax for segmentation.
https://experienceleague.adobe.com/en/docs/experience-platform/segmentation/pql/datetime-functions
The interval function typically is used a function within the Adobe Experience Platform datalake.
I would recommend using the using the operations of <= against the fields on in your statement and use the occurs function.
Hi @GabrielaNa1,
I checked how the UI Audience Builder handles conditions for date-time type attributes. It seems that it does not allow using dynamic variables on both sides of the comparison. Typically, it only supports a direct date value or a fixed offset (e.g., a set number of days).
In your case, since you're comparing one date attribute to another plus a dynamic offset (+30 days
), it might be causing the issue. I'm not entirely sure if this is a limitation, but it’s worth checking with Adobe Support to confirm whether PQL allows this kind of expression.
Hope this helps!
Kind regards,
Parvesh
Thanks, Parvesh,
the syntax I used, with INTERVAL and a dynamic offset, was suggested by Adobe Support. Which makes it even more frustrating that is not working.
I will press on Adobe support for more clarification.
Views
Replies
Total Likes
@GabrielaNa1 Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!
Views
Replies
Total Likes
Hi, I ultimately decided not to use the API audience for this case. The code provided by support was invalid, as there is no INTERVAL function in PQL syntax. We eventually identified the correct way to define the audience through the UI and proceeded with that approach.
Views
Likes
Replies
Views
Likes
Replies