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!
If you have a DateTime field in Crystal Reports, you will see Date and Time tab option on the Format Editor when you right-click on the field and select Format Field menu item. From the Date and Time tab, you may select the desired format and select OK.
To set field default formatting, select File, Options from the menu bar and click the Fields tab. Field formats are set based on the field type you select. There are five field types: String, Number, Currency, Date, and Boolean.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With