I am getting a "Unable to Convert Date/Time from Character String" error message when I run my Access query, but I am not sure why. I have used this method before and have not had any trouble.
SET NOCOUNT ON
DECLARE @StartDate date = '[Start date]', @EndDate date = '[End date]'
SELECT
CAST (Date as Date) as LocalDay
,SalesID
,Status
,Wait
,PO_Number
FROM
cpo_test.dbo.table_agent_detail_view
WHERE Date BETWEEN @StartDate And @EndDate
AND SOURCEID=1
Why is Cast not working in this instance?