set session myconstants.test = '10';
set session myconstants.testb = '10 min';
SELECT now()::time - interval concat (current_setting('myconstants.selfName')::varchar,' min');
SELECT now()::time - INTERVAL '10 min';
set session myconstants.test = '10';
SELECT now()::time - interval current_setting('myconstants.testb')::varchar;
SELECT now()::time - INTERVAL '10 min';
i want add variable in interval function,but current_setting not work..how could i solve it?i use postgres
3
Answers
i found this solution,operator does not exist: timestamp with time zone + integer in PostgreSql.
create + and - operator ,and execute
start_time is timestamp type
You need to cast the variable value to an interval:
The prefix notation
interval '....'
only works with constants following it.You can also try make_interval.