Formatting problem

Hi,
I have encountered a problem when formatting code that uses AT TIME ZONE. 
When I format code like this:

SELECT  CAST(X.CreatedDate AT TIME ZONE 'UTC' AT TIME ZONE X.TimeZone AS datetime) AS CreatedDate
FROM (SELECT  GETUTCDATE() AS CreatedDate, 'E. Australia Standard Time' AS TimeZone)  X;

SELECT  CAST(((X.CreatedDate AT TIME ZONE 'utc' ) AT TIME ZONE X.TimeZone) AS datetime) AS CreatedDate
FROM (SELECT  GETUTCDATE() AS CreatedDate, 'E. Australia Standard Time' AS TimeZone)  X;

The result is this, where the column alias is qualified with the table alias X :

SELECT  CAST(((X.CreatedDate AT TIME ZONE 'utc' ) AT TIME ZONE X.TimeZone) AS datetime) AS X.CreatedDate
FROM (SELECT  GETUTCDATE() AS CreatedDate, 'E. Australia Standard Time' AS TimeZone)  X;


When using a different column alias, the problem does not occur.

Thanks.

Chris.
Tagged:

Answers

Sign In or Register to comment.