<?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: script error when comparing dates in QV Incremental Load in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687709#M726361</link>
    <description>&lt;P&gt;the where statement&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where datetime&amp;gt; '30/3/2017 6:01:28 AM'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;is within a sql statement.&lt;/P&gt;&lt;P&gt;so you need convert the text to date format in the db. and that depends on the db&lt;/P&gt;&lt;P&gt;e.g. if your db is oracle&amp;nbsp;&lt;STRONG&gt;datetime&amp;gt; to_date('30/3/2017 6:01:28 AM','DD/MM/YYYY HH:MI:SS')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Mar 2020 15:05:45 GMT</pubDate>
    <dc:creator>dplr-rn</dc:creator>
    <dc:date>2020-03-25T15:05:45Z</dc:date>
    <item>
      <title>script error when comparing dates in QV Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687683#M726360</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I hope you are doing well.&lt;/P&gt;&lt;P&gt;I am facing the below&amp;nbsp; error when trying to compare dates in Incremental Load implementation.&lt;/P&gt;&lt;P&gt;2020-03-25 15:45:26 0197 drop table MaxKey&lt;BR /&gt;2020-03-25 15:45:26 0202 cp_data2:&lt;BR /&gt;2020-03-25 15:45:26 0203 SQL SELECT CraneID,&lt;BR /&gt;2020-03-25 15:45:26 0204 cp_id,&lt;BR /&gt;2020-03-25 15:45:26 0205 parameter,&lt;BR /&gt;2020-03-25 15:45:26 0206 datetime,&lt;BR /&gt;2020-03-25 15:45:26 0207 RowID,&lt;BR /&gt;2020-03-25 15:45:26 0208 value&lt;BR /&gt;2020-03-25 15:45:26 0209 FROM cp_data&lt;BR /&gt;2020-03-25 15:45:26 0210&lt;BR /&gt;2020-03-25 15:45:26 0211 &lt;STRONG&gt;where datetime&amp;gt; '30/3/2017 6:01:28 AM'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;2020-03-25 15:45:26 Error: Connector reply error: ErrorSource: Microsoft OLE DB Provider for SQL Server, ErrorMsg: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.&lt;/STRONG&gt;&lt;BR /&gt;2020-03-25 15:45:28 Execution Failed&lt;BR /&gt;2020-03-25 15:45:29 Execution finished.&lt;/P&gt;&lt;P&gt;I am not sure conversion is happening here.&lt;/P&gt;&lt;P&gt;Below is the code I have tried and attached the log file for your reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Kindly help me to resolve the issue.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SET ThousandSep=',';&lt;BR /&gt;SET DecimalSep='.';&lt;BR /&gt;SET MoneyThousandSep=',';&lt;BR /&gt;SET MoneyDecimalSep='.';&lt;BR /&gt;SET MoneyFormat='$#,##0.00;($#,##0.00)';&lt;BR /&gt;SET TimeFormat='h:mm:ss TT';&lt;BR /&gt;SET DateFormat='D/M/YYYY';&lt;BR /&gt;SET TimestampFormat='D/M/YYYY h:mm:ss[.fff] TT';&lt;BR /&gt;SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';&lt;BR /&gt;SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';&lt;/P&gt;&lt;P&gt;set _qvd_path = '..\..\..\QVD\QVDfolder\'; //?? The QVD filename&lt;/P&gt;&lt;P&gt;set _qvd_name = 'cp_data2'; //?? The name of the QV table we are loading on the Data Load tab&lt;/P&gt;&lt;P&gt;set vKeyField = RowID; //?? Data Primary Key&lt;/P&gt;&lt;P&gt;set vUpdateField = datetime;&lt;/P&gt;&lt;P&gt;OLEDB CONNECT TO ***&lt;/P&gt;&lt;P&gt;let vFileLen = FileSize('$(_qvd_path)$(_qvd_name).qvd');&lt;/P&gt;&lt;P&gt;trace '&amp;gt;&amp;gt; QVD Size: ' $(vFileLen);&lt;/P&gt;&lt;P&gt;if len('$(vFileLen)') = 0 then&lt;/P&gt;&lt;P&gt;trace 'Full reload begins...';&lt;/P&gt;&lt;P&gt;$(_qvd_name):&lt;BR /&gt;SQL SELECT&lt;BR /&gt;CraneID,&lt;BR /&gt;cp_id,&lt;BR /&gt;parameter,&lt;BR /&gt;datetime,&lt;BR /&gt;RowID,&lt;BR /&gt;value&lt;BR /&gt;FROM cp_data;&lt;/P&gt;&lt;P&gt;let vRows = NoOfRows('$(_qvd_name)');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// Max Date field value into a QVD for the future reload&lt;/P&gt;&lt;P&gt;NewKey:&lt;BR /&gt;load&lt;BR /&gt;num#(max(FieldValue('$(vUpdateField)', RecNo()))) as Key&lt;BR /&gt;AutoGenerate num#(FieldValueCount('$(vUpdateField)'));&lt;/P&gt;&lt;P&gt;let vNewKey = peek('Key', 0, 'NewKey');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let vKeyQVD = 'MaxKey';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$(vKeyQVD):&lt;BR /&gt;load&lt;BR /&gt;'$(vNewKey)' as MaxKey,&lt;BR /&gt;'$(vRows)' as [# of Rows Inserted],&lt;BR /&gt;date(now()) as [Reload DateTime]&lt;BR /&gt;AutoGenerate(1)&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;STORE $(vKeyQVD) into $(_qvd_path)$(vKeyQVD).qvd(qvd);&lt;/P&gt;&lt;P&gt;drop Table NewKey;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Store table data into QVD&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;store $(_qvd_name) into $(_qvd_path)$(_qvd_name).qvd(qvd);&lt;/P&gt;&lt;P&gt;drop table $(_qvd_name);&lt;/P&gt;&lt;P&gt;//5. Reset variables&lt;/P&gt;&lt;P&gt;LET vNewKey = null();&lt;BR /&gt;LET vMaxKey = Null();&lt;BR /&gt;LET vRows = null();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ELSEIF len('$(vFileLen)') &amp;gt; 0 then&lt;/P&gt;&lt;P&gt;TRACE 'Incremental reload begins...';&lt;/P&gt;&lt;P&gt;set vKeyQVD = 'MaxKey';&lt;/P&gt;&lt;P&gt;$(vKeyQVD):&lt;BR /&gt;load&lt;BR /&gt;Timestamp(MaxKey) as MaxKey&lt;BR /&gt;from&lt;BR /&gt;$(_qvd_path)$(vKeyQVD).qvd(qvd);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let vMaxKey = Peek('MaxKey');&lt;/P&gt;&lt;P&gt;trace '&amp;gt;&amp;gt;&amp;gt; Last Max Key value stored: ' &amp;amp; $(vMaxKey);&lt;/P&gt;&lt;P&gt;drop table $(vKeyQVD);&lt;/P&gt;&lt;P&gt;//Perform incremental reload&lt;/P&gt;&lt;P&gt;$(_qvd_name):&lt;BR /&gt;SQL SELECT CraneID,&lt;BR /&gt;cp_id,&lt;BR /&gt;parameter,&lt;BR /&gt;datetime,&lt;BR /&gt;RowID,&lt;BR /&gt;value&lt;BR /&gt;FROM cp_data&lt;/P&gt;&lt;P&gt;where $(vUpdateField)&amp;gt; '$(vMaxKey)';&lt;/P&gt;&lt;P&gt;let vRows = NoOfRows('$(_qvd_name)');&lt;/P&gt;&lt;P&gt;trace 'Total Rows:' $(vRows);&lt;/P&gt;&lt;P&gt;Concatenate($(_qvd_name))&lt;BR /&gt;load&lt;BR /&gt;CraneID,&lt;BR /&gt;cp_id,&lt;BR /&gt;parameter,&lt;BR /&gt;datetime,&lt;BR /&gt;RowID,&lt;BR /&gt;value&lt;BR /&gt;from&lt;BR /&gt;$(_qvd_path)$(_qvd_name).qvd(qvd)&lt;BR /&gt;Where not Exists ([$(vKeyField)]);&lt;/P&gt;&lt;P&gt;// To delete records inner join key field with the QVD table.&lt;/P&gt;&lt;P&gt;inner join($(_qvd_name))&lt;BR /&gt;LOAD&lt;BR /&gt;[$(vKeyField)];&lt;/P&gt;&lt;P&gt;sql select [$(vKeyField)]&lt;BR /&gt;from cp_data;&lt;/P&gt;&lt;P&gt;trace 'Storing table data into QVD';&lt;/P&gt;&lt;P&gt;store $(_qvd_name) into $(_qvd_path)$(_qvd_name).qvd(qvd);&lt;/P&gt;&lt;P&gt;// 7. Store max Primary Key ID for the future incremental reload (QVD)&lt;/P&gt;&lt;P&gt;NewKey:&lt;BR /&gt;load&lt;BR /&gt;num#(max(FieldValue('$(vUpdateField)', RecNo()))) as Key&lt;BR /&gt;AutoGenerate num#(FieldValueCount('$(vUpdateField)'));&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let vNewKey = peek('Key', 0, 'NewKey');&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let vKeyQVD = 'MaxKey';&lt;/P&gt;&lt;P&gt;let vRows = NoOfRows('$(_qvd_name)');&lt;/P&gt;&lt;P&gt;$(vKeyQVD):&lt;BR /&gt;load&lt;BR /&gt;'$(vNewKey)' as MaxKey,&lt;BR /&gt;'$(vRows)' as [# of Rows Inserted],&lt;BR /&gt;date(now()) as [Reload DateTime]&lt;BR /&gt;AutoGenerate(1) ;&lt;/P&gt;&lt;P&gt;drop table NewKey;&lt;/P&gt;&lt;P&gt;STORE $(vKeyQVD) into $(_qvd_path)$(vKeyQVD).qvd(qvd);&lt;/P&gt;&lt;P&gt;//drop table $(_qvd_name);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;EXIT SCRIPT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance,&lt;/P&gt;&lt;P&gt;Sekhar.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:58:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687683#M726360</guid>
      <dc:creator>PRS</dc:creator>
      <dc:date>2024-11-16T00:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: script error when comparing dates in QV Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687709#M726361</link>
      <description>&lt;P&gt;the where statement&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;where datetime&amp;gt; '30/3/2017 6:01:28 AM'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;is within a sql statement.&lt;/P&gt;&lt;P&gt;so you need convert the text to date format in the db. and that depends on the db&lt;/P&gt;&lt;P&gt;e.g. if your db is oracle&amp;nbsp;&lt;STRONG&gt;datetime&amp;gt; to_date('30/3/2017 6:01:28 AM','DD/MM/YYYY HH:MI:SS')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 15:05:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687709#M726361</guid>
      <dc:creator>dplr-rn</dc:creator>
      <dc:date>2020-03-25T15:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: script error when comparing dates in QV Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687736#M726362</link>
      <description>&lt;P&gt;Hello Dilip,&lt;/P&gt;&lt;P&gt;Our source DB is SQL server. Can you please suggest relevant date function with the format.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 15:57:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687736#M726362</guid>
      <dc:creator>PRS</dc:creator>
      <dc:date>2020-03-25T15:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: script error when comparing dates in QV Incremental Load</title>
      <link>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687753#M726363</link>
      <description>&lt;P&gt;i think convert(datetime,&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.w3schools.com/sql/func_sqlserver_convert.asp" target="_blank"&gt;https://www.w3schools.com/sql/func_sqlserver_convert.asp&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Mar 2020 16:29:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/script-error-when-comparing-dates-in-QV-Incremental-Load/m-p/1687753#M726363</guid>
      <dc:creator>dplr-rn</dc:creator>
      <dc:date>2020-03-25T16:29:05Z</dc:date>
    </item>
  </channel>
</rss>

