<?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: Syntax error while trying to calculate a date in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292051#M65168</link>
    <description>&lt;P&gt;You're passing a string literal to the addDate method. You should remove the double quotes.&lt;/P&gt;
&lt;PRE&gt;context.MaxDateSoldeCompta_3M = TalendDate.addDate(context.MaxDateSoldeCompta,"dd/MM/yyyy",-3,"MM");&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Aug 2018 14:57:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-08-03T14:57:54Z</dc:date>
    <item>
      <title>Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292050#M65167</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;I'm trying to extract dates by inserting them into variables context.&lt;/SPAN&gt; &lt;SPAN&gt;Everything works as long as it's just insertion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;But I would like to make a calculation: remove 3 months to the date and store it in another variable with tJavaRow and tDBOracleInput (Date pattern "dd/MM/yyyy")&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;my tJavaRow :&lt;/SPAN&gt;&lt;/P&gt; 
&lt;PRE&gt;context.MaxDateCreation = input_row.MAX_DATECREATION;
context.MaxDateSoldeCompta = input_row.MAX_DATESOLDECOMPTA;
context.MaxDateSoldeCompta_3M = TalendDate.addDate("context.MaxDateSoldeCompta","dd/MM/yyyy",-3,"MM");
System.out.println(context.MaxDateCreation);
System.out.println(context.MaxDateSoldeCompta);
System.out.println(context.MaxDateSoldeCompta_3M);&lt;/PRE&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;But I get this error : &lt;FONT face="courier new,courier"&gt;Error : type mismatch: cannot convert from String to Date&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;I tried this :&lt;/SPAN&gt;&lt;/P&gt; 
&lt;PRE&gt;TalendDate.addDate(TalendDate.parseDate("context.MaxDateSoldeCompta","dd/MM/yyyy"),"dd/MM/yyyy",-3,"MM");&lt;/PRE&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;FONT face="courier new,courier"&gt;Error : The method addDate(String, String, int, String) in the type TalendDate is not applicable for the arguments (Date, String, int, String)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;So I tried this &lt;/SPAN&gt;&lt;/P&gt; 
&lt;PRE&gt;TalendDate.addDate(TalendDate.parseDate("context.MaxDateSoldeCompta","dd/MM/yyyy").toString(),"dd/MM/yyyy",-3,"MM");&lt;/PRE&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;But I fall back on the initial error &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;So my last try was this :&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;PRE&gt;context.MaxDateSoldeCompta_3M = TalendDate.parseDate(TalendDate.addDate("context.MaxDateSoldeCompta","dd/MM/yyyy",-3,"MM"),"dd/MM/yyyy");&lt;/PRE&gt; 
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;Exception in component tJavaRow_1&lt;BR /&gt;java.lang.RuntimeException: dd/MM/yyyy can't support the date!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;My output of my others variables without calculation:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;PRE&gt;Output 
Wed Aug 01 01:44:43 CEST 2018
Tue Jul 31 00:00:00 CEST 2018&lt;/PRE&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;Datatype of my variables is 'Date' (without others specification).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;What is the correct synthax to get what I want ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;SPAN class=""&gt;&lt;SPAN class="short_text"&gt;Thanks &lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 14:17:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292050#M65167</guid>
      <dc:creator>Mayot</dc:creator>
      <dc:date>2018-08-03T14:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292051#M65168</link>
      <description>&lt;P&gt;You're passing a string literal to the addDate method. You should remove the double quotes.&lt;/P&gt;
&lt;PRE&gt;context.MaxDateSoldeCompta_3M = TalendDate.addDate(context.MaxDateSoldeCompta,"dd/MM/yyyy",-3,"MM");&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Aug 2018 14:57:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292051#M65168</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T14:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292052#M65169</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;You re giving the context variable itself in double quotes as "context.MaxDateSoldeCompta". So instead of&amp;nbsp;consumed as a variable, it is consumed as a String.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nikhil Thampi&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 15:00:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292052#M65169</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T15:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292053#M65170</link>
      <description>&lt;P&gt;When I remove the quote "", I had the 2nd error :&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;&lt;FONT face="courier new,courier"&gt;Error : The method addDate(String, String, int, String) in the type TalendDate is not applicable for the arguments (Date, String, int, String)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN class=""&gt;I can't see where the problem comes from, other than the format of the date&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt; 
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt; 
&lt;PRE&gt;Wed Aug 01 01:44:43 CEST 2018&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt; 
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN class=""&gt;This kind of output&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;look very special, however in my DB it display like that "dd/MM/yy"&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I also tried &lt;STRONG&gt;-&lt;/STRONG&gt; instead of &lt;STRONG&gt;/&lt;/STRONG&gt;, &lt;STRONG&gt;yy&lt;/STRONG&gt; instead of &lt;STRONG&gt;yyyy&lt;/STRONG&gt; but always same issue &lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MPcz.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157233iD1A564EF62DE3BC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MPcz.png" alt="0683p000009MPcz.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 15:05:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292053#M65170</guid>
      <dc:creator>Mayot</dc:creator>
      <dc:date>2018-08-03T15:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292054#M65171</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;My first assumption is that you are having the context variable&amp;nbsp;context.MaxDateSoldeCompta in date format.&amp;nbsp; In that case, you will have to use the expression as below to get the 3 month older date.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;TalendDate.addDate(context.input_date,-3,"MM")&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&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-center" image-alt="image.png" style="width: 400px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lz4E.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/152952i3A564412DA13F11A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lz4E.png" alt="0683p000009Lz4E.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Warm Regards,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Nikhil Thampi&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 15:31:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292054#M65171</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T15:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292055#M65172</link>
      <description>&lt;P&gt;OMG it was so simple. &lt;SPAN class=""&gt;And when I think I was trying to convert my Date format into a String&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class=""&gt;Thanks &lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 15:36:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292055#M65172</guid>
      <dc:creator>Mayot</dc:creator>
      <dc:date>2018-08-03T15:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error while trying to calculate a date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292056#M65173</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;No problem at all. Happy to help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Enjoy Talend &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Warm Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nikhil Thampi&lt;/P&gt;</description>
      <pubDate>Fri, 03 Aug 2018 15:38:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Syntax-error-while-trying-to-calculate-a-date/m-p/2292056#M65173</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-08-03T15:38:10Z</dc:date>
    </item>
  </channel>
</rss>

