W
Windmill3mo ago
Sindre

postgres sql bind varaiables

select now() - interval '$1' as end is there a way to get $1 to work
No description
6 Replies
rubenf
rubenf3mo ago
yes, $1::text
Sindre
Sindre3mo ago
Wow. nice AI! thanks
No description
Sindre
Sindre3mo ago
haha. but it did not work :\
Sindre
Sindre3mo ago
did not work either. but then I guess it just how it is
No description
rubenf
rubenf3mo ago
1 year but let me find the fix this works: select interval '1'::text ' year'; so try this: ``` select interval $1::text ' year';
```
select concat($1::text, ' year')::interval;
```
select concat($1::text, ' year')::interval;
Sindre
Sindre3mo ago
thanks! that worked
No description