SQL for Previous Month in AEP Query Tool
Trying to replace a legacy data warehouse job that uses a "Previous Month" time range with a query in AEP. I can get the correct data back from my query if I manually set the start/end dates, but I can't generate working SQL for the rolling previous month time range so I can automate the job. ChatGPT gave me 4 different SQL variations to try but all failed, something like this
AND `timestamp` >= date_trunc(
'month',
date_sub(date_trunc('month', current_timestamp()), 1)
)
AND `timestamp` < date_trunc('month', current_timestamp())
gives this error ErrorCode: 42601 queryId: 09e1ee39-c4b9-4e9f-bedd-d6c0e5ff18af Syntax error encountered. Reason: [line 13:56: missing INTEGER_VALUE at ')']
Has anyone developed working AEP SQL for this?

