<?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 where date format gives wrong results in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189004#M52060</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Blaise,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&amp;lt;pre&amp;gt;select distinct(Datum) from "Match-Online Test".dbo.Partij where month(Datum)=8&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt; &lt;P&gt;done that Query to the SQL Still got the same results.&lt;/P&gt;&lt;P&gt;Got all days to august 29 and 30 and 31 of July (or was it June still can't get those 2 rigth)&lt;/P&gt;&lt;P&gt;But in the next reply there seems to be an answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Sep 2009 12:53:50 GMT</pubDate>
    <dc:creator />
    <dc:date>2009-09-18T12:53:50Z</dc:date>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188990#M52046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello there,&lt;/P&gt;&lt;P&gt;With Qlikview and SQL 2008 a like to get only this month results not last month&lt;/P&gt;&lt;P&gt;When I do a load from SQL on all data en then a where statement in qlikview I get as reuslt all data from this month here is the code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;partij:&lt;BR /&gt;LET dezemaand = num(month(today()));&lt;BR /&gt;load Datum,&lt;BR /&gt; KwekerID,&lt;BR /&gt; ArtikelID&lt;BR /&gt; where month(Datum) = $(dezemaand);&lt;BR /&gt; select * FROM "Match-Online Test".dbo.Partij;&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Then the result is all line with date stamp for this month (september)&lt;BR /&gt;But now I only want to get this date from the SQL DB en this is my code now&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE ___default_attr="plain" class="jive_text_macro jive_macro_code" jivemacro="code"&gt;&lt;BR /&gt;partij:&lt;BR /&gt;LET dezemaand = num(month(today()));&lt;BR /&gt;LOAD * ;&lt;BR /&gt;SELECT Datum,&lt;BR /&gt; KwekerID,&lt;BR /&gt; ArtikelID&lt;BR /&gt;FROM "Match-Online Test".dbo.Partij where month(Datum) = $(dezemaand);&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;And now the are 2 extra days in the line that match this month. Those are 30 and 31 of augustus.&lt;/P&gt;&lt;P&gt;Anyone knows this problem?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 18:10:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188990#M52046</guid>
      <dc:creator />
      <dc:date>2009-09-16T18:10:59Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188991#M52047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only thing I'm not sure about is how the load statement in QlikView is working, certainly in SQL you would need to check the year number as well as the month, otherwise you will get rows for August, but for every year (I'm also not too sure that a comparison to a QVW variable in the SQL statement will work), so your SQL WHERE clause should look like:&lt;/P&gt;&lt;P&gt;WHERE Month(Datum) = Month(GetDate()) AND Year(Datum) = Year(GetDate())&lt;/P&gt;&lt;P&gt;For info, GetDate() in SQL will return today's date.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 18:43:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188991#M52047</guid>
      <dc:creator />
      <dc:date>2009-09-16T18:43:01Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188992#M52048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you store num(date(today())) as a variable and use it in a where statement in a sql select, you won't receive dates from today. Qv and SQL server treats those 'number dates' differently. But, if you do a num(date(today()))-2 you will get the correct dates from the sql statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 19:18:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188992#M52048</guid>
      <dc:creator>blaise</dc:creator>
      <dc:date>2009-09-16T19:18:39Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188993#M52049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;why don't you check your sql query directly (not thru qlikview) like this &lt;P&gt;SELECT Datum, KwekerID, ArtikelIDFROM "Match-Online Test".dbo.Partij where month(Datum) =9;&lt;/P&gt;&lt;P&gt;If this is giving correct result, then there is something to worry in qlikview. Otherwise it shuld be the problem with database/data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 19:40:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188993#M52049</guid>
      <dc:creator />
      <dc:date>2009-09-16T19:40:55Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188994#M52050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got it,&lt;/P&gt;&lt;P&gt;in the statement where Month(Datum) = Month(Getdate())&lt;/P&gt;&lt;P&gt;still give 2 days from last month but when I do&lt;/P&gt;&lt;P&gt;where Month(Datum-2) = Month(Getdate()) it works fine.&lt;/P&gt;&lt;P&gt;Is this strange behaver from qlikview or SQL ???&lt;/P&gt;&lt;P&gt;Now created this one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;let timeformaterror=2;&lt;BR /&gt;let thismonth = num(month(today());&lt;BR /&gt;sql select Datum&lt;BR /&gt;FROM "Match-Online Test".dboPartij&lt;BR /&gt; where Month(Datum- $(timeformaterror) = $(thismonth);&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;And this way when this problems doens't occure anymore we only have to set timeformaterror to 0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 19:53:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188994#M52050</guid>
      <dc:creator />
      <dc:date>2009-09-16T19:53:29Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188995#M52051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai Richy&lt;/P&gt;&lt;P&gt;when I use number 9 still got 2 days from last month&lt;BR /&gt;Also when i Use Getdate statements still 2 days from last month&lt;/P&gt;&lt;P&gt;But with my work around I go on to the next challenge &lt;IMG alt="Cool" src="http://community.qlik.com/emoticons/emotion-11.gif" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 19:58:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188995#M52051</guid>
      <dc:creator />
      <dc:date>2009-09-16T19:58:32Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188996#M52052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;What you have done cannot be a solution. &lt;P&gt;Consider a row having date 01Sep2009. Then by giving -2, the date becomes 30Aug2009, and it will get filtered out by your where clause.&lt;/P&gt;&lt;P&gt;And how did u check the query giving '=9'. Is it from qlikview or from your sql query tool. I wanted you to check from the query tool. If its still giving you wrong results, then atleast keep in mind that there is something wrong with your data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 20:17:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188996#M52052</guid>
      <dc:creator />
      <dc:date>2009-09-16T20:17:23Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188997#M52053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;Let vToday = num(today());&lt;BR /&gt;SQL SELECT DateField from database1.dbo."Company$Invoice" where DateField = $(vToday);&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;will not fetch any values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;Let vToday = num(today())-2;&lt;BR /&gt;SQL SELECT DateField from database1.dbo."Company$Invoice" where DateField = $(vToday);&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Will return a dateField with 2009-09-16 as only value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 20:30:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188997#M52053</guid>
      <dc:creator>blaise</dc:creator>
      <dc:date>2009-09-16T20:30:51Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188998#M52054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hoi Richy,&lt;/P&gt;&lt;P&gt;if done a sql query. (direct on the database with query tools (that is also fun &lt;IMG alt="Yes" src="http://community.qlik.com/emoticons/emotion-21.gif" /&gt;)&lt;/P&gt;&lt;P&gt;with the same code and the result is the same.&lt;/P&gt;&lt;P&gt;Month september and 2 days from august.&lt;/P&gt;&lt;P&gt;So where is this problem coming from? This is an windows 2008 with sql 2008.&lt;/P&gt;&lt;P&gt;Qlikview is on windows 2003 and version 9&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 20:52:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188998#M52054</guid>
      <dc:creator />
      <dc:date>2009-09-16T20:52:13Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188999#M52055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Since you have queried it directly, and result is coming wrong, we don't have to relate it with qlikview. Now u gotta find what is wrong in your database. Try the same query using you query tool, but this time changing months.ie, first try with month(date)= 8, then 7 like that. See if same problem exists.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 20:57:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/188999#M52055</guid>
      <dc:creator />
      <dc:date>2009-09-16T20:57:30Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189000#M52056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Done that already,&lt;/P&gt;&lt;P&gt;The database is from april this year. and all months got the same 2 days in the last month.&lt;/P&gt;&lt;P&gt;I have contacted the software house of the database if the know what is wrong.&lt;/P&gt;&lt;P&gt;But when I read the reply of Blaise He also got the same issue. Or is my English reading not so good yet. (I am a Dutch Guy)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 21:01:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189000#M52056</guid>
      <dc:creator />
      <dc:date>2009-09-16T21:01:53Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189001#M52057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Now i wonder, whether you people consider last two days of a month as next month. &lt;P&gt;Anyway you try one more thing:&lt;/P&gt;&lt;P&gt;SELECT Datum, KwekerID, ArtikelID FROM "Match-Online Test".dbo.Partij where&lt;/P&gt;&lt;P&gt;date('2009-08-01') &amp;lt;= date(Datum) AND date(Datum)&amp;lt;=date('2009-08-31')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Sep 2009 21:28:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189001#M52057</guid>
      <dc:creator />
      <dc:date>2009-09-16T21:28:30Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189002#M52058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you use Toad or some other query tool (like mssql management studio express) you should NOT have a problem with "where month(Datum)=8. This should fetch all dates within August. As Ricky is saying there seems to be a problem in your db (ie not Qv related).&lt;/P&gt;&lt;P&gt;try this query ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;select distinct(Datum) from "Match-Online Test".dbo.Partij where month(Datum)=8&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;This will list all the fetched dates within month(Datum)=8. Also, have a look at the Datum field, is it a datetime format or something other?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Sep 2009 04:01:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189002#M52058</guid>
      <dc:creator>blaise</dc:creator>
      <dc:date>2009-09-17T04:01:45Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189003#M52059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;can recall that this is a very old bug, where MS starts to count the days as from Dec 31st, 1899 and has further "forgotten" to calculate that 1900 was a leapyear. QV counts the Jan 1st, 1900 as day 1. In your example you hand over a numeric value into another system, which has a different time-base. You may deduct the 2 days or hand over the date in a format, which is understood to be interpreted correctly, like:&lt;/P&gt;&lt;P&gt;LET sDate = chr(39) &amp;amp; date(today() , 'MM/DD/YYYY') &amp;amp; chr(39);&lt;/P&gt;&lt;P&gt;and put this into the SQL-statement.&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Sep 2009 22:02:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189003#M52059</guid>
      <dc:creator>prieper</dc:creator>
      <dc:date>2009-09-17T22:02:30Z</dc:date>
    </item>
    <item>
      <title>SQL where date format gives wrong results</title>
      <link>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189004#M52060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Blaise,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&amp;lt;pre&amp;gt;select distinct(Datum) from "Match-Online Test".dbo.Partij where month(Datum)=8&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt; &lt;P&gt;done that Query to the SQL Still got the same results.&lt;/P&gt;&lt;P&gt;Got all days to august 29 and 30 and 31 of July (or was it June still can't get those 2 rigth)&lt;/P&gt;&lt;P&gt;But in the next reply there seems to be an answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Sep 2009 12:53:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/SQL-where-date-format-gives-wrong-results/m-p/189004#M52060</guid>
      <dc:creator />
      <dc:date>2009-09-18T12:53:50Z</dc:date>
    </item>
  </channel>
</rss>

