<?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: Fiscal Year Logic Java Script Syntax in tMap Expression in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296697#M69332</link>
    <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/00539000006yqfZAAQ"&gt;@nfz11&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks your solution worked!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2019 16:08:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-09T16:08:30Z</dc:date>
    <item>
      <title>Fiscal Year Logic Java Script Syntax in tMap Expression</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296693#M69328</link>
      <description>&lt;P&gt;Hello Talend Community,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I need to create some Fiscal Year Logic based off a Date Column in a tMap Expression. The format of the date is in MM/DD/YYYY format. I want to convert it to YYYYMMDD. I do this with this expression&amp;nbsp;TalendDate.formatDate("yyyyMMdd",TalendDate.parseDate("MM/dd/yyyy",row1.Date))&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Now I need to grab the Month Value out of "yyyyMMdd" format (MM) and if the Month is greater than or equal 7(July) Then 1 + yyyy, Else yyyy.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Fiscal Year begins in July and Ends in June so I need to make a FiscalYear Output Column based off a date column.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If anyone can help me out with the logic in a tMap Expression it would be greatly appreicated&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks!&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;-Andrew&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 21:49:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296693#M69328</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-07T21:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Fiscal Year Logic Java Script Syntax in tMap Expression</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296694#M69329</link>
      <description>&lt;P&gt;This is the expression you would need to get the fiscal year:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;Mathematical.INT(TalendDate.formatDate("MM",row1.date)) &amp;lt; 7  ?
Mathematical.INT(TalendDate.formatDate("yyyy",row1.date)) : Mathematical.INT(TalendDate.formatDate("yyyy",row1.date))+1 &lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The "? :" idiom is called the ternary operator and is used in Java as well as other languages.&amp;nbsp; By the way, Talend does not use JavaScript, it uses Java.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;This is a screenshot of my test job showing the expression in the tMap:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="test-fy.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4BJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/130871i6D13F2C82AFACBAB/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4BJ.png" alt="0683p000009M4BJ.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;This is the output:&lt;/P&gt; 
&lt;PRE&gt;.-------------------------.
|      #1. tLogRow_1      |
+------------+------------+
| key        | value      |
+------------+------------+
| date       | 02/01/2019 |
| fiscalYear | 2019       |
+------------+------------+

.-------------------------.
|      #2. tLogRow_1      |
+------------+------------+
| key        | value      |
+------------+------------+
| date       | 08/01/2019 |
| fiscalYear | 2020       |
+------------+------------+&lt;/PRE&gt; 
&lt;P&gt;I am also attaching the archive of my test job.&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LvFn"&gt;FiscalYearTest.zip&lt;/A&gt;</description>
      <pubDate>Wed, 08 May 2019 07:45:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296694#M69329</guid>
      <dc:creator>nfz11</dc:creator>
      <dc:date>2019-05-08T07:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Fiscal Year Logic Java Script Syntax in tMap Expression</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296695#M69330</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/00539000006yqfZAAQ"&gt;@nfz11&lt;/A&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I'm getting this error whenever I try to Run my Job. Remember my Date Data is in a String Format not in a Date format. Is that the issue?&lt;/P&gt; 
&lt;P&gt;In the Input Column its in a String Format with MM/dd/YYYY. Do I need to Convert it into a Date data type to be able to perform the logic you listed below?&lt;/P&gt; 
&lt;P&gt;If you can show the syntax for this maybe I can pass it through a variable and then use the variable instead of the actual input column&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="error.PNG" style="width: 683px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4Fo.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155599i3228CC998C8285BF/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4Fo.png" alt="0683p000009M4Fo.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DateError.PNG" style="width: 913px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4Vp.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133646iABA8CE11BF6476F1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4Vp.png" alt="0683p000009M4Vp.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;Thanks for the help though I'm thinking its going to work if I convert the string into a Date first&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 20:49:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296695#M69330</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-08T20:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fiscal Year Logic Java Script Syntax in tMap Expression</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296696#M69331</link>
      <description>&lt;P&gt;Yes, my example assumes your field has a type of Date.&amp;nbsp; It is better practice to pass dates around as Date objects rather than strings.&amp;nbsp; You can download and import my test project and look at it to see how I created Date objects to test.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;To answer your follow-up inquiry, yes you could create an intermediate Date variable in tMap using the parseDate function.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;You can convert your strings to dates and then back again like:&lt;/P&gt; 
&lt;PRE&gt;Mathematical.INT(TalendDate.formatDate("MM",TalendDate.parseDate("MM/dd/yyyy",row1.date))) &amp;lt; 7 ?&lt;BR /&gt;Mathematical.INT(TalendDate.formatDate("yyyy",TalendDate.parseDate("MM/dd/yyyy",row1.date))) : Mathematical.INT(TalendDate.formatDate("yyyy",TalendDate.parseDate("MM/dd/yyyy",row1.date)))+1 &lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If you want to play around with strings you could use the substring function to extract the month and year:&lt;/P&gt; 
&lt;PRE&gt;Mathematical.INT(row1.date.substring(0,2)) &amp;lt; 7 ?&lt;BR /&gt;Mathematical.INT(row1.date.substring(6,10)) : Mathematical.INT(row1.date.substring(6,10))+1 &lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;You really should take a tutorial on using Talend's built-in functions.&amp;nbsp; They are all actually Java, but you don't have to learn all of Java, you can just learn the functions like&amp;nbsp;Mathematical.INT and TalendDate.formatDate.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 00:19:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296696#M69331</guid>
      <dc:creator>nfz11</dc:creator>
      <dc:date>2019-05-09T00:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fiscal Year Logic Java Script Syntax in tMap Expression</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296697#M69332</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/00539000006yqfZAAQ"&gt;@nfz11&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks your solution worked!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2019 16:08:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Fiscal-Year-Logic-Java-Script-Syntax-in-tMap-Expression/m-p/2296697#M69332</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-09T16:08:30Z</dc:date>
    </item>
  </channel>
</rss>

