I want to add my i
variable in the date_trunc. My i
variable has value 10. This is a piece of my code :
date_trunc('month', now()) - interval 'i month'
error:
pq: invalid input syntax for type interval: "i month"
您可以使用算术:
date_trunc('month', now()) - i * interval '1 month'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.