<?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: Loop job over date range set in global variable in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287177#M60799</link>
    <description>&lt;P&gt;The above code should not ask you for input. My assumption was that you would already have your start and end date globalMap variables populated. If not, you will need to do this. Once that is done, if you run the code it will produce you a list of dates in the output window.&lt;/P&gt;</description>
    <pubDate>Thu, 02 May 2019 11:04:48 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-02T11:04:48Z</dc:date>
    <item>
      <title>Loop job over date range set in global variable</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287174#M60796</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I'm trying to get my job to loop over a date range, and pass the date it is looping for to a tmap further down the chain so the date it is looping for can be captured in a database.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have two variables set as global variables.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;"varStartDate" = TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(), -7, "dd"));
"varEndDate" = TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(), 0, "dd"))&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I then have a tJava component:&lt;/P&gt; 
&lt;PRE&gt;java.util.Date start_date=TalendDate.parseDate("yyyy-MM-dd", (String)globalMap.get("varStartDate"));
java.util.Date end_date=TalendDate.parseDate("yyyy-MM-dd", (String)globalMap.get("varEndDate"));
long l=TalendDate.diffDate(end_date, start_date);
globalMap.put("iterate", l);&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I followed this tutorial but having no luck.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;A title="Is it possible to use tloop to loop from a start date thru end date?" href="https://community.talend.com/t5/Design-and-Development/resolved-Is-it-possible-to-use-tloop-to-loop-from-a-start-date/td-p/83538" target="_blank" rel="noopener"&gt;https://community.talend.com/t5/Design-and-Development/resolved-Is-it-possible-to-use-tloop-to-loop-from-a-start-date/td-p/83538&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;is there a simpler approach?&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 05:57:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287174#M60796</guid>
      <dc:creator>DavidETL</dc:creator>
      <dc:date>2024-11-16T05:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop job over date range set in global variable</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287175#M60797</link>
      <description>&lt;P&gt;I suspect the issue is that you are just getting the date difference in days, but doing anything with it. Run this code in a tJava and see if this is what you want...&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;java.util.Date start_date=TalendDate.parseDate("yyyy-MM-dd", (String)globalMap.get("varStartDate"));
java.util.Date end_date=TalendDate.parseDate("yyyy-MM-dd", (String)globalMap.get("varEndDate"));
l=TalendDate.diffDate(end_date, start_date);&lt;BR /&gt;
Date new_start_date;
&lt;BR /&gt;for(int i=0; i&amp;lt;=l; i++){
      new_start_date = TalendDate.addDate(start_date, i, &lt;SPAN class="s1"&gt;"dd"&lt;/SPAN&gt;);
      System.out.println(TalendDate.formatDate(&lt;SPAN class="s1"&gt;"yyyy-MM-dd"&lt;/SPAN&gt;, new_start_date));
}
&lt;/PRE&gt; 
&lt;P&gt;What I am doing here is appending days to the start_date in a loop based on the number of days difference. I think you need to slightly modify your job to follow this sort of logic.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 10:14:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287175#M60797</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-01T10:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop job over date range set in global variable</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287176#M60798</link>
      <description>Thanks for the reply. When I use the code provided it asks for input. 
&lt;BR /&gt; 
&lt;BR /&gt;Ideally what I'd like is to create a list of dates, and feed it into a tFlowToIterate component. Currently, I have it working off an SQL view but want to switch it, so a user enters a start date and end date into a tsmgbox, which is then passed to a global var (for later use), and then the dates between the list and moved to the TFlowToIterate. 
&lt;BR /&gt; 
&lt;BR /&gt;is there a way to produce a virtual table of dates between a range in Talend I can pass to a tflowtoIterate component?</description>
      <pubDate>Thu, 02 May 2019 05:01:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287176#M60798</guid>
      <dc:creator>DavidETL</dc:creator>
      <dc:date>2019-05-02T05:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Loop job over date range set in global variable</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287177#M60799</link>
      <description>&lt;P&gt;The above code should not ask you for input. My assumption was that you would already have your start and end date globalMap variables populated. If not, you will need to do this. Once that is done, if you run the code it will produce you a list of dates in the output window.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 11:04:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287177#M60799</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-02T11:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loop job over date range set in global variable</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287178#M60800</link>
      <description>&lt;P&gt;thank you, all good&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2019 07:03:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287178#M60800</guid>
      <dc:creator>DavidETL</dc:creator>
      <dc:date>2019-05-03T07:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Loop job over date range set in global variable</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287179#M60801</link>
      <description>&lt;P&gt;&lt;A href="https://community.qlik.com/s/profile/005390000069RuGAAU"&gt;@rhall&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;I want to pass a date variable to a sql query, and write the query result into a flat file. So there will be a file for each date variable passed. I found this post helpful, at least I could get a list of dates within the required range. Here is the test I did using the codes you and others provided:&lt;/P&gt; 
&lt;P&gt;&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="setGlobalVar.JPG" style="width: 590px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M77Z.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139849i3DD9A040311BE7C7/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M77Z.jpg" alt="0683p000009M77Z.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&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="PrintList.JPG" style="width: 620px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M77e.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139638i5D4B622525BD13DF/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M77e.jpg" alt="0683p000009M77e.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PrintResult.JPG" style="width: 401px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M77a.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153687i8AD29D18AC294F16/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M77a.jpg" alt="0683p000009M77a.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;But then what's the next? How could I pass each and every new_start_date into my child job&lt;/P&gt; 
&lt;P&gt;(which would create the flat file for each date passed in)?&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 00:28:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Loop-job-over-date-range-set-in-global-variable/m-p/2287179#M60801</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-22T00:28:55Z</dc:date>
    </item>
  </channel>
</rss>

