如何在Crystal Reports中将DateTime对象转换为字符串 [英] How to convert DateTime object to string in Crystal Reports

查看:490
本文介绍了如何在Crystal Reports中将DateTime对象转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Crystal Reports代码行:

  EffectiveDateTimeString = ToText({Command.EffectiveDate},dd -MM-yyyy hh:mm:ss); 

但是,当我尝试验证公式时,我得到一个错误,太多的参数给定该功能,选择dd-MM-yyyy hh:mm:ss。 Command.EffectiveDate是DateTime对象。如何将它转换为字符串?



谢谢!

解决方案

您需要使用赋值运算符:= ,而不是等价一个 =

  EffectiveDateTimeString:= ToText({Command.EffectiveDate},dd-MM-yyyy hh:mm:ss); 

* 编辑*



此代码段可按预期工作:

  ToText(CurrentDate + CurrentTime,dd-MM-yyyy hh:mm: ss); 

确保您的字段实际上返回的是日期/时间,而不是一个或另一个。 p>

I have a simple line of Crystal Reports code below:

EffectiveDateTimeString = ToText({Command.EffectiveDate} , "dd-MM-yyyy hh:mm:ss" );

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?

Thanks!

解决方案

You need to use the assignment operator :=, not the equivalency one =:

EffectiveDateTimeString := ToText({Command.EffectiveDate} , "dd-MM-yyyy hh:mm:ss" );

*edit *

This snippet works as expected:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆