如何在 Crystal Reports 中将 DateTime 对象转换为字符串 [英] How to convert DateTime object to string in Crystal Reports
本文介绍了如何在 Crystal Reports 中将 DateTime 对象转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面有一行简单的 Crystal Reports 代码:
I have a simple line of Crystal Reports code below:
EffectiveDateTimeString = ToText({Command.EffectiveDate} , "dd-MM-yyyy hh:mm:ss" );
但是,当我尝试验证公式时,我收到一条错误消息,提示已为此函数提供了太多参数"并选择了dd-MM-yyyy hh:mm:ss".Command.EffectiveDate 是 DateTime 对象.如何将其转换为字符串?
However, when I try to validate the formula, I get a error saying "Too many arguments have been given to this function" with "dd-MM-yyyy hh:mm:ss" selected. Command.EffectiveDate is the DateTime object. How can I convert this to a string?
谢谢!
推荐答案
你需要使用赋值运算符:=
,而不是等价的=
:
You need to use the assignment operator :=
, not the equivalency one =
:
EffectiveDateTimeString := ToText({Command.EffectiveDate} , "dd-MM-yyyy hh:mm:ss" );
*编辑 *
此代码段按预期工作:
ToText(CurrentDate + CurrentTime, "dd-MM-yyyy hh:mm:ss");
确保您的字段实际上返回的是日期/时间,而不是其中一个.
Ensure that your field is actually returning a date/time, rather than one or the other.
这篇关于如何在 Crystal Reports 中将 DateTime 对象转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文