【问题标题】:Extract year from cognos report expression从 cognos 报告表达式中提取年份
【发布时间】:2016-05-10 21:34:42
【问题描述】:

我想在报表表达式字段中提取当前年份,去年,但无法获取。 date2timestamp(Today())Today() 这可以很好地获取日期

_add_years(date2timestamp(Today()),1)extract("year",Today()) 但这显示错误。 我想在我的报告中动态显示 2016、2015 作为交叉表节点的标题。

【问题讨论】:

    标签: cognos cognos-10 cognos-bi cognos-8


    【解决方案1】:

    如果你使用布局计算试试

    substring(date2string(Today()),1,4)
    

    当前年份。和

    string2int32(substring(date2string(Today()),1,4)) - 1
    

    上一年。

    【讨论】:

    • 我收到错误RSV-VAL-0002 invalid expression extract(year, current_date). CRX-YXX-4010 a parsing error was found at or near the position 8 in the expression " extract(year, current_date) "
    • 你在使用Layout计算吗?
    • 我想动态显示交叉表节点成员。感谢您的努力,但它仍然不适合我:(
    • 试试 Report Studio 的内置日期 current_date
    【解决方案2】:

    当前年份: extract('year', date2timestamp(today()))

    上一年: extract('year', _add_years(date2timestamp(today()), -1))

    这将为您提供一个整数值,您可以使用日期项目属性中的普通 数据格式 选项对其进行格式化,例如,如果需要,可以删除千位逗号。

    【讨论】:

      【解决方案3】:

      使用两个数据项进行查询。

      对于上一年,一个数据项将具有:

      extract (year, _add_years(current_date, -1)) 
      

      对于当年:

      extract (year, current_date).  
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-28
        • 1970-01-01
        相关资源
        最近更新 更多