<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Error using Year() function into a SQL SELECT statement in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315773#M1196597</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks. Perhaps the 2nd option it could be useful for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Mar 2011 17:55:54 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-03-22T17:55:54Z</dc:date>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315767#M1196591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I have tried to use the Year function into a SQL SELECT statement. I'm using QV 10 SR1.&lt;/P&gt;&lt;P&gt;I have written:&lt;/P&gt;&lt;P&gt;Tbl1:&lt;/P&gt;&lt;P&gt;LOAD Year(myDate) as YYYY&lt;/P&gt;&lt;P&gt;SQL SELECT Year(myDate) FROM myDB.dbo.myTable&lt;/P&gt;&lt;P&gt;STORE Tbl1 INTO c:\qvapp\myTables.QVD&lt;/P&gt;&lt;P&gt;and I have myDate field not found error.&lt;/P&gt;&lt;P&gt;Any helps to me, please? Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 14:37:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315767#M1196591</guid>
      <dc:creator />
      <dc:date>2011-03-22T14:37:33Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315768#M1196592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There is no myDate field coming from the SQL part:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Tbl1:LOAD Year(myDate) AS YYYY; // provided myDate is a date field formatted as suchSQL SELECT myDateFROM myDB.dbo.myTable; STORE Tbl1 INTO C:\qvapp\myTables.QVD;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;According to your code above, the name of the field would be "Year(myDate)" because you are not renaming in the SQL part.&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 14:46:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315768#M1196592</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-03-22T14:46:56Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315769#M1196593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks,&lt;/P&gt;&lt;P&gt;but this syntax is right:&lt;/P&gt;&lt;P&gt;Tbl1: LOAD myDate as DDDD; SQL SELECT myDate FROM myDb.dbo.myTable;&lt;/P&gt;&lt;P&gt;but this not (it is a bit strange!):&lt;/P&gt;&lt;P&gt;Tbl1: LOAD Year(myDate) as YYYY; SQL SELECT Year(myDate) FROM myDb.dbo.myTable;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 15:07:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315769#M1196593</guid>
      <dc:creator />
      <dc:date>2011-03-22T15:07:14Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315770#M1196594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="jive_text_macro jive_macro_quote" jivemacro="quote"&gt;&lt;BR /&gt;pscorca69 wrote:&lt;BR /&gt;but this not (it is a bit strange!):&lt;BR /&gt;Tbl1: LOAD &lt;B&gt;&lt;I&gt;"Year(myDate)"&lt;/I&gt;&lt;/B&gt; as YYYY; SQL SELECT &lt;B&gt;Year(myDate)&lt;/B&gt; FROM myDb.dbo.myTable;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;The name of the field in the SQL part is Year(myDate) (bold), so you need to double quote it in the LOAD part (bold italic).&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 15:22:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315770#M1196594</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-03-22T15:22:38Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315771#M1196595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, but with double quote equally I have that Year(myDate) doesn't found.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 15:41:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315771#M1196595</guid>
      <dc:creator />
      <dc:date>2011-03-22T15:41:52Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315772#M1196596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured that. So you have to rename the field in either the LOAD part or the SQL part to get it work (because you don't know how the field "Year(myDate)" is actually called in SQL):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Tbl1: LOAD Year as YYYY; SQL SELECT &lt;B&gt;Year(myDate) AS Year&lt;/B&gt; FROM myDb.dbo.myTable;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Tbl1: LOAD Year(myDate) as YYYY; SQL SELECT &lt;B&gt;myDate&lt;/B&gt; FROM myDb.dbo.myTable;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 15:47:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315772#M1196596</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2011-03-22T15:47:29Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315773#M1196597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, thanks. Perhaps the 2nd option it could be useful for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2011 17:55:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315773#M1196597</guid>
      <dc:creator />
      <dc:date>2011-03-22T17:55:54Z</dc:date>
    </item>
    <item>
      <title>Error using Year() function into a SQL SELECT statement</title>
      <link>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315774#M1196598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im new to QlickView, but know my way around SQL&lt;/P&gt;&lt;P&gt;It seems that QlickView associates the column name with the column name returned from SQL.&lt;/P&gt;&lt;P&gt;If you perform the query in SQL Query analyser you will notice it has a blank column name:&lt;/P&gt;&lt;P&gt;SELECT Year(myDate) FROM myDB.dbo.myTable&lt;/P&gt;&lt;P&gt;This is indirectly what Miguel said in the first reply.&lt;/P&gt;&lt;P&gt;To get around this you need to alias it:&lt;/P&gt;&lt;P&gt;SELECT Year(myDate) &lt;STRONG&gt;as&lt;/STRONG&gt; &lt;STRONG&gt;myDate&lt;/STRONG&gt; FROM myDB.dbo.myTable&lt;/P&gt;&lt;P&gt;I think this will resolve the problem if you simply add that to the SQL statement as per your original post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2011 20:06:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Error-using-Year-function-into-a-SQL-SELECT-statement/m-p/315774#M1196598</guid>
      <dc:creator />
      <dc:date>2011-03-23T20:06:20Z</dc:date>
    </item>
  </channel>
</rss>

