<?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>article Transformation: Date Time - Invalid Value - MySQL in Official Support Articles</title>
    <link>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/ta-p/1826202</link>
    <description>&lt;H4&gt;Environment&lt;/H4&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;LI-PRODUCT title="Qlik Replicate" id="qlikReplicate"&gt;&lt;/LI-PRODUCT&gt;&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Table/Field level transformation&lt;/LI&gt;
&lt;LI&gt;mySQL Source&amp;nbsp;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="font-style: italic;"&gt;The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.&lt;/P&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3 id="toc-hId--525350720"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Date Transformation&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P&gt;Some databases allow for non-standard date time values which when replicated to a target database that does not allow the same "Bad" value the task will error out.&lt;/P&gt;
&lt;P&gt;An example of this is a replication task the has mySQl as the source and Snowflake as the target.&lt;BR /&gt;We have a mysql DB with few tables having datetime data as 0000-00-00 00:00:00 , when we are trying to load this data into snowflake we are running into below error.&lt;/P&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3 id="toc-hId--525350720"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Task Log Error&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P&gt;00010461: 2021-07-23T17:09:30 [TARGET_LOAD ]E: RetCode: SQL_ERROR SqlState: 22007 NativeError: 100035 Message: Timestamp '0000-00-00 00:00:00' is not recognized&lt;/P&gt;
&lt;P&gt;Any way we can apply a global transformation on the data to change it from 0000-00-00 00:00:00&lt;BR /&gt;To 1970-01-01 00:00:00?&lt;/P&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;H3 id="toc-hId--525350720"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;Global Transformation&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P&gt;Since there is no easy way to know if a table will always have good data values the best place to do this type of check and replace is on the Task's Global Transformation Screen. There is a global transformation type called Replace column value which we will use and it will apply to all date fields in all the tables of the task.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The complete transformation code as follows:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;coalesce(
CASE WHEN substr($AR_M_SOURCE_COLUMN_DATA,1,4) = '0000'
THEN '1970-01-01 00:00:00'
WHEN substr($AR_M_SOURCE_COLUMN_DATA,1,4) = ''
THEN '1970-01-01 00:00:00'
ELSE
$AR_M_SOURCE_COLUMN_DATA
END
,$AR_M_SOURCE_COLUMN_DATA)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H3&gt;&amp;nbsp;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;Replace Column Value: screenshots&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The following set of 4 screenshots show where and how to configure the Global Transformation Solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Replace Column Value" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/59576iB0E0AC116927A9BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Replcate column values.PNG" alt="Replace Column Value" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Replace Column Value&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When in the Global Transformation Screen select Replace column value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Transformation Scope" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/59577i859B472D1F559BC4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tarnsformation Scope.PNG" alt="Transformation Scope" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Transformation Scope&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Select Data Type "DATETIME" to configure the task to apply this to all fields of type Date Time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Transformation Action" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/59578iB4FC05F02CACC62A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Tarnsformation Action.PNG" alt="Transformation Action" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Transformation Action&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Click on Create Expression to add the transformation code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Expression Builder" style="width: 913px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/59579i88B0435E5B9A4FA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Expression.PNG" alt="Expression Builder" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Expression Builder&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add the transformation code that checks for a "Bad" date value in this case zero's or empty string and then set the value to "1970-01-01 00:00:00" which is an acceptable date for Snowflake target.&lt;/P&gt;
&lt;H3 id="toc-hId--525350720"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;NON Global Transformation&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;Non Global solution at the source DB - Table and field specific&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;On the column within the table itself. &lt;BR /&gt;Here is what I've done for the column MyColumn in the table MyTable:&lt;/P&gt;
&lt;P&gt;CASE &lt;BR /&gt;WHEN substr($MyColumn, 1, 4) = '0000' &lt;BR /&gt;THEN NULL&lt;BR /&gt;ELSE $MyColumn&lt;BR /&gt;END&lt;/P&gt;</description>
    <pubDate>Thu, 30 Sep 2021 21:00:58 GMT</pubDate>
    <dc:creator>Michael_Litz</dc:creator>
    <dc:date>2021-09-30T21:00:58Z</dc:date>
    <item>
      <title>Transformation: Date Time - Invalid Value - MySQL</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/ta-p/1826202</link>
      <description>&lt;P&gt;Replicate global transformation to detect and replace bad date values&lt;/P&gt;</description>
      <pubDate>Thu, 30 Sep 2021 21:00:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/ta-p/1826202</guid>
      <dc:creator>Michael_Litz</dc:creator>
      <dc:date>2021-09-30T21:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: Transformation: Date Time - Invalid Value - MySQL</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/tac-p/1833714#M4176</link>
      <description>&lt;P&gt;What are the situations when Replicate writes&amp;nbsp;&lt;SPAN&gt;0000-00-00 00:00:00 as the value on target?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is this a limitation in Replicate? If yes, when can we expect a permanent fix?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 17:15:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/tac-p/1833714#M4176</guid>
      <dc:creator>Prabodh</dc:creator>
      <dc:date>2021-09-03T17:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Transformation: Date Time - Invalid Value - MySQL</title>
      <link>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/tac-p/1833957#M4188</link>
      <description>&lt;P&gt;Hi Prabodh,&lt;/P&gt;&lt;P&gt;By default, Replicate applies the same value captured from the source. So if both source and target allow this value, it would be applied like this. If the target does not allow it, you can use the article above to overcome the conflict.&lt;/P&gt;&lt;P&gt;If you find another scenario where Replicate applies this value and the actual data in the source was not '&lt;SPAN&gt;0000-00-00 00:00:00', it requires investigation, so kindly open a support ticket.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 11:14:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Official-Support-Articles/Transformation-Date-Time-Invalid-Value-MySQL/tac-p/1833957#M4188</guid>
      <dc:creator>harel_barash</dc:creator>
      <dc:date>2021-09-06T11:14:48Z</dc:date>
    </item>
  </channel>
</rss>

