I hope someone can advise on the issue I'm having.
This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '
By adding in this condition, I now get the following error:
Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.
I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.
(The CONVERT function is being used in setup for a PIVOT SQL which needs VARCHAR for column headers)
Thanks in advance for your help,
declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''
View Complete Post