Problem with Keyword YEAR in a view

Database
N/A

Problem with Keyword YEAR in a view

Why does this work....

sel YEAR(Date-1) as TEST_YR

But this does not...

replace view dbowner.TEST_V as
( sel YEAR(Date-1) as TEST_YR ) ;

Is there a simple syntax work around I am missing here to use the keyword function YEAR in a view? Thank you!
1 REPLY
Enthusiast

Re: Problem with Keyword YEAR in a view

You are running the query through SQL Assistant and if you look in Tools/ Options/ Query you will see that Allow Use of ODBC Extensions In Queries is allowed.
Microsoft ODBC interface is translating your query to what Bill thinks you want.

Turn this off and run the query again, and you get syntax error.

Microsoft ODBC interface does not attempt to translate DDL statements, so you get an error with or without that option.

Use:

replace view TEST_V as
sel Extract(YEAR from Current_Date - 1) as TEST_YR

That will always work.