Skip to Content
0
Jul 28, 2023 at 08:22 PM

"A date-time is required here." only in Crystal Reports Viewer

284 Views Last edit Jul 28, 2023 at 09:34 PM 3 rev

I have a report which has only one data source table, a Command that contains the following SQL query:

Select i.InvoiceNumber, 
i.InvoiceDate as InvoiceDateTime
, Cast(i.InvoiceDate as date) as InvoiceDateString
FROM Invoice i

When I generate the report in SAP Crystal Reports 2020, my Command.InvoiceDate field is returned as a DateTime data type and InvoiceDateString is returned as a String [10] data type.

I have a formula named CDate in the report that gets the day from Command.InvoiceDateString:

day(cdate({Command.InvoiceDateString}))

When I preview the report in SAP Crystal Reports 2020, the formula returns the day as a number, which is expected.

However, when I run the same report in Crystal Reports Viewer (CR Runtime 13.0 sp33) , I received the error

Error in formula  CDate: 
'day(cdate({Command.InvoiceDateString}))
'
A date-time is required here.

Workaround: If I use the DateTime field, Command.InvoiceDateTime, then it works fine.