A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi @Bruce Minchinton ,
Actually the convert of [Order].CompletedDate would not affect your where part and result. Your query could be working as before.
But we recommend you to use below query and you could check whether it is working.
SELECT
CONVERT (Date, [Order].CompletedDate) As DateOnly
,OrderType.Name
,[Order].OrderTotal
,[Order].Discount
FROM
OrderType
INNER JOIN [Order]
ON OrderType.OrderTypeId = [Order].OrderTypeId
WHERE
[Order].CompletedDate >= @CompletedDate
AND [Order].CompletedDate < DATEADD(DAY, 1, @CompletedDate2)
Above assumes @CompletedDate and @CompletedDate2 are always passed as dates with no time.
If there is time involved (e.g. the app might pass now()) then you can round off using:
WHERE [Order].CompletedDate >= CONVERT(DATE, @CompletedDate)
AND [Order].CompletedDate < CONVERT(DATE, DATEADD(DAY, 1, @CompletedDate2));
If above or your query is still not working, please provide some sample data and expected output, we could check further.
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.