【问题标题】:Crystal Reports: Grouping by dateCrystal Reports:按日期分组
【发布时间】:2015-01-16 04:59:48
【问题描述】:

感谢您查看我的问题。

我正在尝试按报告修订日期对水晶报告进行分组,我有 4 个不同的类别。基本上,我试图将报告分组:过期、30 天内到期、30-90 天内到期和 90 天后到期。

  1. 如果 {reviseddate} 为
  2. 如果 {reviseddate} 为 > {currentdate} 且
  3. 如果 {reviseddate} 为 >= {currentdate} + 31 天且
  4. 如果 {reviseddate} 是 >= {currentdate} + 91 天,那么这些到期时间已超过 90 天。

我不擅长日期编码,可以使用一些指导来了解如何在 Crystal Reports (2008) 中编写此代码。希望我解释得对。

非常感谢你,迈克

【问题讨论】:

    标签: crystal-reports basic


    【解决方案1】:

    首先在任何分组之前创建一个类似这样的公式字段(伪代码)

    if ({reviseddate} <= {currentdate}) then 1
    else if (({reviseddate} > {currentdate} ) and ({reviseddate} < DateAdd("d", 30 , {currentdate}) )) then 2
    else if (({reviseddate} >= DateAdd("d", 31 , {currentdate}) ) and ({reviseddate} <= DateAdd("d", 90 , {currentdate}) )) then 3
    else if (({reviseddate} >= DateAdd("d", 91 , {currentdate}) ) then 4
    

    然后将您的公式放在详细信息部分。一旦您看到您的公式按预期生成了 1、2、3、4 值,然后在公式字段上进行分组。

    注意事项:

    1. 使用 Crystal Report 的 DateAdd 函数 DateAdd("d", 30 , {currentdate}) 来处理天数的添加
    2. 如果您的日期字段作为字符串而不是日期进入 Crystal,请先使用 DateValue 函数将它们转换为日期。

    【讨论】:

    • 谢谢 Douglas,我会试一试并报告。
    猜你喜欢
    • 1970-01-01
    • 2023-03-04
    • 2012-10-13
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多