简体   繁体   English

水晶报表-FORMULA

[英]Crystal Report-FORMULA

I am trying to create two FORMULA fields in Crystal Reports with the same Column in the Database using the following Syntax: 我正在尝试使用以下语法在数据库中具有相同列的Crystal Reports中创建两个FORMULA字段:

FORMULA1- COLL_DATE
if Collection_Rejection_Desc = 'Cleared'
then Coll_Rej_Dt
else null

FORMULA2- REJ_DATE
if Collection_Rejection_Desc = 'Rejected'
then Coll_Rej_Dt
else null

But it is giving me error saying "a Date and Time Field is expected here" 但这给了我一个错误,说“这里需要一个日期和时间字段”

How can I resolve this? 我该如何解决?

You may want to return Coll_Rej_Dt when the condition is correct, otherwise return null . 您可能希望在条件正确时返回Coll_Rej_Dt ,否则返回null

you can use Switch by replace if condition. 您可以使用条件替换替换开关。 Because in if condition, you need to return same data type in true part and false part. 因为在if条件下,您需要在真部分和假部分中返回相同的数据类型。

So, try this... 所以,尝试一下...

Switch (Collection_Rejection_Desc = 'Cleared', Coll_Rej_Dt)

Switch (Collection_Rejection_Desc = 'Rejected', Coll_Rej_Dt)

this will return value when the condition is true. 当条件为真时,它将返回值。

you can't give one value as date time and other as null in a if condition.. change like this: 您不能在if条件中给定一个值作为日期时间,而另一个给定为null。

FORMULA1- COLL_DATE 公式1-COLL_DATE

if Collection_Rejection_Desc = 'Cleared' 
then ToText(Coll_Rej_Dt) 
else ""

FORMULA2- REJ_DATE 公式2-REJ_DATE

if Collection_Rejection_Desc = 'Rejected'
then ToText(Coll_Rej_Dt )
else ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM