postgresql - 如果月份是十二月,则年份增加 1

标签 postgresql pentaho

我在 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/

相关文章:

sql - 我可以在 Pentaho Report Designer 的查询中使用用户定义的数据库函数吗?

pentaho水壶: get row count from stream

exception - JDK 1.8 上安装问题 : pentaho 5. 1 ce

java - 是否有支持嵌套组的 Spring Security DefaultLdapAuthoritiesPopulator 实现?

java - 如何在 PostgreSQL 上使用 java.lang.NumberFormatException 执行 liquibase

sql - 使用 'IN' 运算符组合两个查询时如何提高性能

postgresql - Eclipselink 和 Postgresql 批量编写

json - Pentaho Kettle - 从 JSON 表输出到 Postgresql JSONB 字段

postgresql - 访问启动触发器的行

postgresql - 为什么我在 Windows 10 的 pgAdmin 中看不到 PostgreSQL 9.5?