[英]ERROR: operator does not exist: timestamp without time zone + integer
i am adding nthmonth (2) in my postgresql function , but at the time of execution it showing error "ERROR: operator does not exist: timestamp without time zone + integer" HINT: No operator matches the given name and argument type(s). 我在我的postgresql函数中添加了nthmonth(2),但是在执行时它显示错误“ ERROR:运算符不存在:没有时区的时间戳+整数”提示:没有运算符匹配给定的名称和参数类型。 You might need to add explicit type casts.
您可能需要添加显式类型转换。 QUERY: SELECT pi_date + nthMonth ||
查询:SELECT pi_date + nthMonth || ' month ' :: INTERVAL
'月'::间隔
DECLARE
beginMonth timestamp;
pi_date timestamp := to_timestamp('14-Jan-2016 01:50 AM,'DD-MON-YYYY HH:MI AM);
> beginMonth := pi_date + nthMonth || ' month ' :: INTERVAL;
It's fairly obvious - the "+" is binding more tightly than the "||" 很明显-“ +”的绑定比“ ||”的绑定更紧密 (as it is telling you).
(正告诉您)。
You want something like: 您想要类似的东西:
pi_date + (nthMonth || ' months'::interval)
Or, perhaps a little clearer: 或者,也许更清晰一些:
pi_date + (nthMonth * interval '1 month')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.