I'm trying to execute the following stored procedure with a dynamic date parameter so that it picks up 6 months ago to yesterday.
When I run on a server with US language settings it works however when I run on a server with UK language settings I get the error:
Conversion failed when converting date and/or time from character string
I have tried converting the date to YYYYMMDD as this works on all servers however I have been unable to - I have even tried to force into a VARCHAR but no luck :(
Is there a way to get the date as YYYYMMDD format? Hope you can help.
USE Reports
DECLARE @DteStart DATETIME2(3)
DECLARE @DteEnd DATETIME2(3)
SELECT @DteStart = DATEADD(MM, DATEDIFF(MM, 0, CONVERT(DATE,GETDATE(),103))-6,0)
SELECT @DteEnd = DATEADD(DD, DATEDIFF(DD, 0, CONVERT(DATE,GETDATE(),103))-1,0)
EXEC [dbo].[spReportsMyData] @DteStart, @DteEnd;