<?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 SQL code conversion to Qlikview for use with QVDs **HELP!** in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345157#M127600</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I understood, you'd like to use the SQL syntax in Qlikview script for example when loading data.&lt;/P&gt;&lt;P&gt;If that's so, you can use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;if(IsNull(Field1), 'N/A', Field1) as Field1,&lt;/P&gt;&lt;P&gt;Mid(Field2, 8, 1) as Field2,&lt;/P&gt;&lt;P&gt;Interval(Date(DateField2, 'DD/MM/YYYY') - Date(DateField1, 'DD/MM/YYYY'), 'D') as NumberOfDays&lt;/P&gt;&lt;P&gt;From TestFile.qvd(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the interval function, you can divide it by 30, 31 or 30.43685 (365.242199/12), and use Round or Floor to get an integer.&lt;/P&gt;&lt;P&gt;You may also want to use the fabs() function to get the absolute value in case Date2 is smaller than Date1 and you are using the Floor() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'd have for example:&lt;/P&gt;&lt;P&gt;Round(Interval(Date(DateField2, 'DD/MM/YYYY') - Date(DateField1, 'DD/MM/YYYY'), 'D')/30) as NumberOfMonths.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if you can still read from your sql database to create your qvds, i'd suggest you keep using your sql syntax as below:&lt;/P&gt;&lt;P&gt;LOAD FORWARDER_ID, PROG, MONTH_DIFF;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: &amp;amp;quot;Arial&amp;amp;quot;,&amp;amp;quot;sans-serif&amp;amp;quot;; font-size: 8pt;"&gt;CASE WHEN FORWARDER_ID IS NULL THEN 'N/A' ELSE FORWARDER_ID END AS FORWARDER_ID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: &amp;amp;quot;Arial&amp;amp;quot;,&amp;amp;quot;sans-serif&amp;amp;quot;; font-size: 8pt;"&gt;SUBSTR(VINTAGE_CODE,8,1) AS PROG,&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #333333; font-family: &amp;amp;quot;Arial&amp;amp;quot;,&amp;amp;quot;sans-serif&amp;amp;quot;; font-size: 8pt;"&gt;MONTHS_BETWEEN(FILE_DATE, ACCT_CHG_OFF_DATE) AS MONTH_DIFF&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;FROM ...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will ensure you get the same result as SQL especially regarding the number of months between two dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Jun 2012 13:45:33 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-06-09T13:45:33Z</dc:date>
    <item>
      <title>SQL code conversion to Qlikview for use with QVDs **HELP!**</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345156#M127599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 10pt;"&gt;Hi, I am new to Qlikview and still fresh to SQL/Oracle. I have been teaching myself as I go with success. I am currently converting some of our business's SQL written QV reports to run off new Qvds I have created.I have done some searching in the manual with no luck. I have taken a crack at my version of these to no avail, could someone help me so I have futureexamples of these?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 8pt;"&gt;CASE WHEN FORWARDER_ID IS NULL THEN 'N/A' ELSE FORWARDER_ID END AS FORWARDER_ID &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #333333; font-size: 8pt; font-family: 'Arial','sans-serif';"&gt;SUBSTR(VINTAGE_CODE,8,1) AS PROG &lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial','sans-serif'; color: #333333; font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #333333; font-size: 8pt; font-family: 'Arial','sans-serif';"&gt;MONTHS_BETWEEN(FILE_DATE, ACCT_CHG_OFF_DATE) AS MONTH_DIFF &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jun 2012 20:54:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345156#M127599</guid>
      <dc:creator>MalcolmCICWF</dc:creator>
      <dc:date>2012-06-08T20:54:51Z</dc:date>
    </item>
    <item>
      <title>SQL code conversion to Qlikview for use with QVDs **HELP!**</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345157#M127600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I understood, you'd like to use the SQL syntax in Qlikview script for example when loading data.&lt;/P&gt;&lt;P&gt;If that's so, you can use the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;if(IsNull(Field1), 'N/A', Field1) as Field1,&lt;/P&gt;&lt;P&gt;Mid(Field2, 8, 1) as Field2,&lt;/P&gt;&lt;P&gt;Interval(Date(DateField2, 'DD/MM/YYYY') - Date(DateField1, 'DD/MM/YYYY'), 'D') as NumberOfDays&lt;/P&gt;&lt;P&gt;From TestFile.qvd(qvd);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding the interval function, you can divide it by 30, 31 or 30.43685 (365.242199/12), and use Round or Floor to get an integer.&lt;/P&gt;&lt;P&gt;You may also want to use the fabs() function to get the absolute value in case Date2 is smaller than Date1 and you are using the Floor() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'd have for example:&lt;/P&gt;&lt;P&gt;Round(Interval(Date(DateField2, 'DD/MM/YYYY') - Date(DateField1, 'DD/MM/YYYY'), 'D')/30) as NumberOfMonths.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if you can still read from your sql database to create your qvds, i'd suggest you keep using your sql syntax as below:&lt;/P&gt;&lt;P&gt;LOAD FORWARDER_ID, PROG, MONTH_DIFF;&lt;/P&gt;&lt;P&gt;SQL SELECT&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: &amp;amp;quot;Arial&amp;amp;quot;,&amp;amp;quot;sans-serif&amp;amp;quot;; font-size: 8pt;"&gt;CASE WHEN FORWARDER_ID IS NULL THEN 'N/A' ELSE FORWARDER_ID END AS FORWARDER_ID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333; font-family: &amp;amp;quot;Arial&amp;amp;quot;,&amp;amp;quot;sans-serif&amp;amp;quot;; font-size: 8pt;"&gt;SUBSTR(VINTAGE_CODE,8,1) AS PROG,&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="color: #333333; font-family: &amp;amp;quot;Arial&amp;amp;quot;,&amp;amp;quot;sans-serif&amp;amp;quot;; font-size: 8pt;"&gt;MONTHS_BETWEEN(FILE_DATE, ACCT_CHG_OFF_DATE) AS MONTH_DIFF&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;FROM ...;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will ensure you get the same result as SQL especially regarding the number of months between two dates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Jun 2012 13:45:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345157#M127600</guid>
      <dc:creator />
      <dc:date>2012-06-09T13:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL code conversion to Qlikview for use with QVDs **HELP!**</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345158#M127601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, everthying worked just fine and now I have examples to look back on in the future!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jun 2012 19:31:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-code-conversion-to-Qlikview-for-use-with-QVDs-HELP/m-p/345158#M127601</guid>
      <dc:creator>MalcolmCICWF</dc:creator>
      <dc:date>2012-06-14T19:31:48Z</dc:date>
    </item>
  </channel>
</rss>

