<?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 Re: Qlikview converts date to nvarchar when calling SQL procedure in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981901#M973496</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The select statement that is sent to the ODBC driver &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;is a string&lt;/EM&gt;&lt;/SPAN&gt;. Hence, it is &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;not possible&lt;/EM&gt;&lt;/SPAN&gt; to send anything but characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make sure that the dollar expansion of the variables generates the correct characters, you should make sure that the variable has a text representation that is the one you want. Hence, you should - just as Massimo suggests - use the Date() function to create the format the database expects when you create the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A href="https://community.qlik.com/qlik-blogpost/2830"&gt;Data Types in QlikView&lt;/A&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;, &lt;/SPAN&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4002"&gt;The Date Function&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 06 Sep 2015 11:31:02 GMT</pubDate>
    <dc:creator>hic</dc:creator>
    <dc:date>2015-09-06T11:31:02Z</dc:date>
    <item>
      <title>Qlikview converts date to nvarchar when calling SQL procedure</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981898#M973493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm calling a SQL procedure from Qlikview.&amp;nbsp; The SQL procedure has two input variables (@Start and @End).&amp;nbsp; I have a Start and End input boxes in Qlikview. My code is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;ODBC CONNECT TO Trial_Database;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL EXEC [Trial_Database].[dbo].[RunAll] @Start = '$(Start)', @End = '$(End)';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the problem is that when loading this procedure, I get the error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Error converting data type varchar to date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL EXEC [Trial_Database].[dbo].[RunAll] @Start = '01/01/2013', @End = '&lt;STRONG&gt;41820&lt;/STRONG&gt;'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is that why does Qlikview convert the @End variable to the integer equivalent of the date?&amp;nbsp; Anybody know any fixes?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Sep 2015 07:00:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981898#M973493</guid>
      <dc:creator />
      <dc:date>2015-09-06T07:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview converts date to nvarchar when calling SQL procedure</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981899#M973494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;before you call the proc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;let NewStart=date($(Start));&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13.3333px;"&gt;let NewEnd=date($(End));&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13.3333px;"&gt;trace $(NewStart)&amp;nbsp; $(NewEnd);&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt; ODBC CONNECT TO Trial_Database;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;EM&gt;SQL EXEC [Trial_Database].[dbo].[RunAll] @Start = '$(Start)', @End = '$(End)';&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;if the NewDate isn't in the correct SQL format you can format in this way adding the 2nd param to date function (adapt YYYYMMDD)&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;EM&gt;let NewStart=date($(Start), 'YYYYMMDD');&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Sep 2015 07:19:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981899#M973494</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2015-09-06T07:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview converts date to nvarchar when calling SQL procedure</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981900#M973495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Massimo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried your coding but now, the problem is reversed.&amp;nbsp; The variable @End is fixed but @Start is not fixed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The variable for @Start = 1/1/2013 but when I use the date function on @Start, it return 12/30/1899.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, when I open the variable overview, I can see that the variable name End has a value 41820 while the value Start has a value 01/01/2013.&amp;nbsp; Any thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Sep 2015 08:28:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981900#M973495</guid>
      <dc:creator />
      <dc:date>2015-09-06T08:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview converts date to nvarchar when calling SQL procedure</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981901#M973496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The select statement that is sent to the ODBC driver &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;is a string&lt;/EM&gt;&lt;/SPAN&gt;. Hence, it is &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;not possible&lt;/EM&gt;&lt;/SPAN&gt; to send anything but characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To make sure that the dollar expansion of the variables generates the correct characters, you should make sure that the variable has a text representation that is the one you want. Hence, you should - just as Massimo suggests - use the Date() function to create the format the database expects when you create the variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See &lt;A href="https://community.qlik.com/qlik-blogpost/2830"&gt;Data Types in QlikView&lt;/A&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;, &lt;/SPAN&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4002"&gt;The Date Function&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Sep 2015 11:31:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981901#M973496</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2015-09-06T11:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview converts date to nvarchar when calling SQL procedure</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981902#M973497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys for this.&amp;nbsp; I really appreciate the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Joel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Sep 2015 02:42:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-converts-date-to-nvarchar-when-calling-SQL-procedure/m-p/981902#M973497</guid>
      <dc:creator />
      <dc:date>2015-09-07T02:42:41Z</dc:date>
    </item>
  </channel>
</rss>

