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.taiwan.businessobjects.com/
支援服務
http://www.taiwan.businessobjects.com/support/
產品說明文件網站
http://support.businessobjects.com/documentation/