3

Query with AT TIME ZONE executed as expected in SQL Server 2016. But if I am adding same query in SQL Server project of Visual Studio 2015, I get a build error

Incorrect Syntax near "AT TIME ZONE".

Code:

DECLARE @Result DATETIME
DECLARE @InputDate DATETIME
        @TimeZone NVARCHAR(50)    

SET @Result = @InputDate AT TIME ZONE @TimeZone AT TIME ZONE 'UTC'

Can anyone help me to fix this issue?

1 Answer 1

5

AT TIME ZONE APPLIES TO:

  • SQL Server (starting with 2016)
  • Azure SQL Database

ONLY.

Change your sql server project type to SQL Server 2016 (or Microsoft Azure SQL Database V12).

1
  • AT TIME ZONE is supported in Azure SQL Database, but when you switch your project target to Azure, it fails to compile. 2016+ work, but then you can't deploy to Azure. Any suggestions?
    – Rob Prouse
    Jan 10, 2020 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.