It doesn't work. The error reads:
Line 1: Incorrect syntax near '@LO866c64011'.
Incorrect syntax near the keyword 'AS'.
The full generated query is:
SELECT [bkngdb].[dbo].[BookingDeliveryNote].[BookerName], [bkngdb].[dbo].[BookingDeliveryNote].[Cancelled], [bkngdb].[dbo].[BookingDeliveryNote].[ClientName], [bkngdb].[dbo].[BookingDeliveryNote].[ContactEmail], [bkngdb].[dbo].[BookingDeliveryNote].[ContactName], CONVERT(@LO866c64011, FLOOR(CONVERT(@LO4bed2e2b2, [bkngdb].[dbo].[BookingDeliveryNote].[DateAdded]))) AS [Date Added], [bkngdb].[dbo].[BookingDeliveryNote].[DeliveryMethod], [bkngdb].[dbo].[BookingDeliveryNote].[Destination], [bkngdb].[dbo].[BookingDeliveryNote].[BookingRef], [bkngdb].[dbo].[BookingDeliveryNote].[HoldReason], [bkngdb].[dbo].[BookingDeliveryNote].[HoldTicketIssue], [bkngdb].[dbo].[BookingDeliveryNote].[InitialAgent], [bkngdb].[dbo].[BookingDeliveryNote].[LeadPassengerName], [bkngdb].[dbo].[BookingDeliveryNote].[Origin], [bkngdb].[dbo].[BookingDeliveryNote].[Printed], [bkngdb].[dbo].[BookingDeliveryNote].[Ticket], CONVERT(@LO866c64013, FLOOR(CONVERT(@LO4bed2e2b4, [bkngdb].[dbo].[BookingDeliveryNote].[TravelDate]))) AS [Travel Date], (SELECT TOP 1
COUNT(DISTINCT [bkngdb].[dbo].[BookingRefund].[BookingRef]) AS [BookingRef] FROM [bkngdb].[dbo].[BookingRefund] WHERE ( [bkngdb].[dbo].[BookingDeliveryNote].[BookingRef] = [bkngdb].[dbo].[BookingRefund].[BookingRef])) AS [Refunded], [bkngdb].[dbo].[BookingDeliveryNote].[DeliveryAddress], [bkngdb].[dbo].[BookingDeliveryNote].[NonIssueRequested], [bkngdb].[dbo].[BookingDeliveryNote].[NonIssued] FROM [bkngdb].[dbo].[BookingDeliveryNote] WHERE ( ( [bkngdb].[dbo].[BookingDeliveryNote].[Printed] = @Printed5 AND [bkngdb].[dbo].[BookingDeliveryNote].[Cancelled] = @Cancelled6 AND [bkngdb].[dbo].[BookingDeliveryNote].[Branch] = @Branch7 AND [bkngdb].[dbo].[BookingDeliveryNote].[LeadPassengerName] = @LeadPassengerName8)) ORDER BY [bkngdb].[dbo].[BookingDeliveryNote].[Ticket] ASC
Parameter: @LO866c64011 : String. Length: 8. Precision: 0. Scale: 0. Direction: Input. Value: "DATETIME".
Parameter: @LO4bed2e2b2 : String. Length: 5. Precision: 0. Scale: 0. Direction: Input. Value: "FLOAT".
Parameter: @LO866c64013 : String. Length: 8. Precision: 0. Scale: 0. Direction: Input. Value: "DATETIME".
Parameter: @LO4bed2e2b4 : String. Length: 5. Precision: 0. Scale: 0. Direction: Input. Value: "FLOAT".
Parameter: @Printed5 : Boolean. Length: 0. Precision: 1. Scale: 0. Direction: Input. Value: 0.
Parameter: @Cancelled6 : Boolean. Length: 0. Precision: 1. Scale: 0. Direction: Input. Value: 0.
Parameter: @Branch7 : AnsiString. Length: 3. Precision: 0. Scale: 0. Direction: Input. Value: "001".
Parameter: @LeadPassengerName8 : AnsiString. Length: 50. Precision: 0. Scale: 0. Direction: Input. Value: "".
I tried with and without a field alias and got the same error.
I had to adapt the code as I use VB and I gave you a simplified example. The actual code here was:
fields("Travel Date").ExpressionToApply = New DbFunctionCall("CONVERT", New Object() {"DATETIME", New DbFunctionCall("FLOOR", New Object() {New DbFunctionCall("CONVERT", New Object() {"FLOAT", EvolviDeliveryNoteFields.TravelDate})})})