<?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: Context variable date in mysql query in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240045#M27664</link>
    <description>Hi David 
&lt;BR /&gt;I can confirm that the query is correct, maybe there is no records match the condition. Try to change the where condition as below for example and see you get records return. 
&lt;BR /&gt;where `RecordCreated`&amp;lt; '"+context.BatchTime+ "'" 
&lt;BR /&gt;Another possible reason is that the context variable is not initialized value before using it, can you upload a screenshot of your job design? 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Shong</description>
    <pubDate>Sun, 12 Aug 2012 05:57:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-08-12T05:57:38Z</dc:date>
    <item>
      <title>Context variable date in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240043#M27662</link>
      <description>Hi,
&lt;BR /&gt;I am having a problem with a datetime context variable in a tMysqlInput component. My query does not return any results, but when I substitute the context variable for the string '2012-08-12 09:18:01' I get results as expected.
&lt;BR /&gt;So here is my situation.
&lt;BR /&gt;- The context variable is defined as a string.
&lt;BR /&gt;- I write the current datetime to the variable (context.BatchTime using a tJava component with: 
&lt;BR /&gt; context.BatchTime = TalendDate.getDate("yyyy-MM-dd hh:mm:ss");
&lt;BR /&gt;- In my tMysqlInput query I have the following:
&lt;BR /&gt;"SELECT 
&lt;BR /&gt; `invoicedata`.`RecordCreated`, 
&lt;BR /&gt; `invoicedata`.`meterID`, 
&lt;BR /&gt; `invoicedata`.`identifierID`, 
&lt;BR /&gt;FROM `invoicedata`
&lt;BR /&gt;where `RecordCreated`= '"+context.BatchTime+ "'"
&lt;BR /&gt;I have read numerous posts on this subject but I cant see what I am doing wrong. Could a nice Talend expert point me in the right direction please?
&lt;BR /&gt;thanks,
&lt;BR /&gt;David</description>
      <pubDate>Sun, 12 Aug 2012 03:38:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240043#M27662</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-12T03:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Context variable date in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240044#M27663</link>
      <description>I have to say I can't see anything wrong with what you've done; the common mistake is to forget the single-quote date-delimiters but you have those. 
&lt;BR /&gt;I suggest you add a tJava connected from tMysqlInput with OnSubjobOK with the code: System.out.println((String)globalMap.get("tMysqlInput_2_QUERY")); to see exactly what the SQL is that is being used.</description>
      <pubDate>Sun, 12 Aug 2012 05:32:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240044#M27663</guid>
      <dc:creator>alevy</dc:creator>
      <dc:date>2012-08-12T05:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Context variable date in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240045#M27664</link>
      <description>Hi David 
&lt;BR /&gt;I can confirm that the query is correct, maybe there is no records match the condition. Try to change the where condition as below for example and see you get records return. 
&lt;BR /&gt;where `RecordCreated`&amp;lt; '"+context.BatchTime+ "'" 
&lt;BR /&gt;Another possible reason is that the context variable is not initialized value before using it, can you upload a screenshot of your job design? 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Shong</description>
      <pubDate>Sun, 12 Aug 2012 05:57:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240045#M27664</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-12T05:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Context variable date in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240046#M27665</link>
      <description>Shong and Alevy, 
&lt;BR /&gt;thank you very much for your prompt and informative replies. Embarrassingly in the end it was user error (me) that was at fault. I was writing the date to mysql incorrectly and that's why the query was not working. 
&lt;BR /&gt;Alevy thanks for the tip about: System.out.println((String)globalMap.get("tMysqlInput_2_QUERY")); I will use this in future to debug my queries. 
&lt;BR /&gt;And a final word about Talend - it is awesome! I am doing things with it that I never thought I could achieve. I love it! 
&lt;BR /&gt;thanks, 
&lt;BR /&gt;David</description>
      <pubDate>Mon, 13 Aug 2012 05:27:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-variable-date-in-mysql-query/m-p/2240046#M27665</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-08-13T05:27:45Z</dc:date>
    </item>
  </channel>
</rss>

