我在 pentaho 中将年份和月份分别作为参数传递,并将月份加 1 并转换为日期格式。我这样写加入年月日。
('${year}' || '-' || '${month}'+1 || '-' || 1 )::date
我需要将现有日期的月份增加 1。如果月份是 December(12) ,新日期月份将为 1(一月),年份将为下一年。
例如:2012-12-30 新日期将是 2013-01-30
如何在 postgreSQl 中为此编写查询?
最佳答案
在将其转换为日期后添加月份:
('${year}' || '-' || '${month}' || '-' || 1 )::date + interval '1' month
关于postgresql - 如果月份是十二月,则年份增加 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28404636/