Kaz ^v^
DTDrizzle Team
•Created by Kaz ^v^ on 3/1/2024 in #help
Trying to pass a variable in .having()
My having clause is like this:
.having(
({ endAt }) =>
sql
date_trunc('day', ${subEndAt}) = CURRENT_DATE + INTERVAL ${sql
${intervalDays}}
,
);
I am fetching endAt in the query, but I have multiple intervals like '3 days', '5 days'.
When I try passing intervalDays as string i get an syntax error, but instead of intervalDays if I set it as 3 days the query works fine.
Is there a way where we can pass it using a variable or do we need to create a separate query for each of the intervals?8 replies