如何使用整数字段添加日期

how can I add date with an integer field

在 PostgreSQL 中 在一个应用程序中,我们从会员那里获取信息,他们账户的到期日期(时间戳)是 "the date of today + the period of time that their account type shows":例如今天是 2020-01-06,他们选择黄金账户,即 9 个月(我定义为整数) ,所以它们的到期日期应该是:2020-10-06 简而言之编写该代码的最佳方式是什么?

您可以使用 * 进行以下简单乘法运算:

select the_date + interval '1 month' * your_integer_column from your_table;

在此处查看演示:http://sqlfiddle.com/#!17/66247/1/0