Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Trying to pass a variable in .having() - Drizzle Team
DT
Drizzle Team
•
2y ago
•
7 replies
Kaz
Trying to pass a variable in .having()
My having clause is like this
:
.having
(
(
{ endAt
}
)
=
>
sql
date_trunc('day', ${subEndAt}) = CURRENT_DATE + INTERVAL ${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
?
Drizzle Team
Join
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
Trying to pass transactions or db
DT
Drizzle Team / help
16mo ago
[HELP]: I'm trying to re-create a CTE-insert in drizzle, having some difficulties
DT
Drizzle Team / help
3y ago
Unwanted db.execute() behavior; trying to pass in an array instead of a record or its singular
DT
Drizzle Team / help
3y ago
how do you pass a query in a typesafe way?
DT
Drizzle Team / help
3y ago