Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to build SQL Server project with "AT TIME ZONE" in Visual Studio 2015

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?

like image 517
Swapnali Hadawale Avatar asked Feb 01 '26 13:02

Swapnali Hadawale


1 Answers

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).

like image 75
Muhammad Saqlain Avatar answered Feb 03 '26 09:02

Muhammad Saqlain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!