JS activity or Query Activity
Hi there,
I have a requirement where I need to determine whether the DateOnly(column1 + 11 days) is greater than the DateOnly(column2 + 21 days). If this condition is met, I'll return column1 and check if it matches today's current date. Otherwise, I'll return column2 and check if it matches today's current date.
I've set up a query activity to retrieve a group of audiences, and now I need to filter out the audience further based on the above conditions and qualified users need to be processed further in the workflow. I'm wondering if this filtering can be done directly through the query activity itself, or if I need to use a JavaScript (JS) activity instead.
If it needs to be done through a JS activity, I would appreciate it if you could provide some sample code references.
I understand that this can be achieved using a CASE statement, as shown below, but I'm uncertain if it's possible through the JS activity:
SELECT
CASE
WHEN DATE_ADD(column1, INTERVAL 11 DAY) > DATE_ADD(column2, INTERVAL 21 DAY) THEN DATE_ADD(column1, INTERVAL 11 DAY)
WHEN DATE_ADD(column2, INTERVAL 21 DAY) > DATE_ADD(column1, INTERVAL 11 DAY) THEN DATE_ADD(column2, INTERVAL 21 DAY)
END AS final_result
FROM
your_table_name
WHERE
CASE
WHEN DATE_ADD(column1, INTERVAL 11 DAY) > DATE_ADD(column2, INTERVAL 21 DAY) THEN DATE_ADD(column1, INTERVAL 11 DAY)
WHEN DATE_ADD(column2, INTERVAL 21 DAY) > DATE_ADD(column1, INTERVAL 11 DAY) THEN DATE_ADD(column2, INTERVAL 21 DAY)
END = CURRENT_DATE;
