Crystal Reports for Rational Application Developer 设计员指南

日期范围(Crystal 语法)

“范围数据类型(Crystal 语法)”一节中讨论了此类函数。值得注意的是,由上述函数产生的“日期”范围取决于当前的日期。例如,如果今天的日期是 1999 年 9 月 18 日,则 LastFullMonth 就是“日期范围”值:
CDate(#Aug 1, 1999#) To CDate(#Aug 31, 1999#)
该功能通常很有用,但如果想根据数据库字段(如 {订单.订单日期})确定日期范围,可以改用日期/时间函数。
例如:
Local DateVar d := CDate ({Orders.Order Date});
Local DateVar Range dr;
dr := DateSerial (Year(d), Month(d) - 1, 1) To
DateSerial (Year(d), Month(d), 1 - 1);
//At this point dr is the Date Range value holding
//the last full month before {Orders.Order Date}
DateSerial 函数使之变得简单易行,因为您不必担心特殊情况。它决不会让您创建无效日期。例如,DateSerial (1999, 1 - 1, 1) 是 1998 年 12 月 1 日。

注意: 在上例中,{订单.订单日期} 实际上是日期时间型字段,因此 CDate 函数通过截断时间部分将其转换为日期。



Business Objects,SAP 子公司
http://www.china.businessobjects.com/
支持服务
http://www.china.businessobjects.com/support/
Web 上的产品文档
http://support.businessobjects.com/documentation/