Search code examples
c#datetimecrystal-reports

Crystal report converting DateTime to string Too many arguments have been given to this function


I have a simple formula like below in crystal report:

iif(isnull({employ.createdDate}),"", ToText({employ.createdDate}, "dd-MMM-yyyy"))

The {employ.createdDate} is in below format:

02/09/2015 10:48:25

It works fine when {employ.createdDate} is null, but when it's not null, the below error message shows:

  Too many arguments have been given to this function 
  Error in File employeeInfo.rpt: 
  Error in formula txtDate

Removing the "dd-MMM-yyyy" does solve the problem but I would like to format the date to "dd-MMM-yyyy" format i.e. "09-FEB-2015"

What's wrong with the formula?


Solution

  • Oh I figured it out...

    The 02/09/2015 10:48:25 is in string format, so I need to convert it to date and convert it to string, I modified the formula to this, and it works:

    ToText(cDate({employ.createdDate}),"dd-MMM-yyyy")