<?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: Subtract specific time interval from a given date in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217830#M13264</link>
    <description>Hi, 
&lt;BR /&gt;To do that very simple, let me specify the different step : 
&lt;BR /&gt;1/ Expand the Code (from your Talend repository); then right-click on Routines and choose "Create Routine"; name it myRoutines and Finish. 
&lt;BR /&gt;2/ When the Routine Editor is Open; move after the Hello Example method (after line 52); add an empty line. 
&lt;BR /&gt;3/ Then copy the following method expression code which does your expected function : 
&lt;BR /&gt; 
&lt;BR /&gt; private static Calendar cal = Calendar.getInstance(); 
&lt;BR /&gt; /** 
&lt;BR /&gt; * getDateMinusADay: return the dateToChange substract ONE DAY (consistancy maintain for FEBRUARY or YEAR Change etc...) 
&lt;BR /&gt; * {talendTypes} Date 
&lt;BR /&gt; * {Category} User Defined 
&lt;BR /&gt; * {param} Date("dateToChange") dateToTest from the source 
&lt;BR /&gt; * {example} getDateMinusADay(dateToChange) 
&lt;BR /&gt; */ 
&lt;BR /&gt; public static Date getDateMinusADay(Date dateToChange) { 
&lt;BR /&gt; cal.setTime(dateToChange); 
&lt;BR /&gt; cal.add(cal.DATE, -1); 
&lt;BR /&gt; return cal.getTime(); 
&lt;BR /&gt; } 
&lt;BR /&gt; 
&lt;BR /&gt;4/ Save your routine, then open your Job, go back to your tMap, choose the button to open the expression editor into the COLUMN you want to tranform and then choose the User Defined function "getDateMinusADay" and fill the right argument. 
&lt;BR /&gt;5/ Save your tMap and Job and execute it : it works !! 
&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;BR /&gt;Best regards;</description>
    <pubDate>Thu, 12 Aug 2010 00:05:13 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-08-12T00:05:13Z</dc:date>
    <item>
      <title>Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217829#M13263</link>
      <description>Hello,&lt;BR /&gt;I have a table with Datetime column 'Week' (end of week date)&lt;BR /&gt;I need to subtract a day from this date.&lt;BR /&gt;In Teradata it works like this&lt;BR /&gt; select currentdate()-1 gives me yesterday date&lt;BR /&gt;In MySQL I would do this:&lt;BR /&gt; select DATE_SUB(now(), interval 1 day)&lt;BR /&gt;Now I want to do it in Talend without going on developign whole new application in Java to calcualte what I need. Is it possible in Talend?&lt;BR /&gt;I have tMySQLInput -&amp;gt; tMap -&amp;gt; tMySQLOutput components and hope to be able to do it in tMap.&lt;BR /&gt;Are there components which would allow me to pass calcualtions to database?&lt;BR /&gt;Thanks a lot for help!&lt;BR /&gt;Pit.</description>
      <pubDate>Sat, 16 Nov 2024 13:19:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217829#M13263</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T13:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217830#M13264</link>
      <description>Hi, 
&lt;BR /&gt;To do that very simple, let me specify the different step : 
&lt;BR /&gt;1/ Expand the Code (from your Talend repository); then right-click on Routines and choose "Create Routine"; name it myRoutines and Finish. 
&lt;BR /&gt;2/ When the Routine Editor is Open; move after the Hello Example method (after line 52); add an empty line. 
&lt;BR /&gt;3/ Then copy the following method expression code which does your expected function : 
&lt;BR /&gt; 
&lt;BR /&gt; private static Calendar cal = Calendar.getInstance(); 
&lt;BR /&gt; /** 
&lt;BR /&gt; * getDateMinusADay: return the dateToChange substract ONE DAY (consistancy maintain for FEBRUARY or YEAR Change etc...) 
&lt;BR /&gt; * {talendTypes} Date 
&lt;BR /&gt; * {Category} User Defined 
&lt;BR /&gt; * {param} Date("dateToChange") dateToTest from the source 
&lt;BR /&gt; * {example} getDateMinusADay(dateToChange) 
&lt;BR /&gt; */ 
&lt;BR /&gt; public static Date getDateMinusADay(Date dateToChange) { 
&lt;BR /&gt; cal.setTime(dateToChange); 
&lt;BR /&gt; cal.add(cal.DATE, -1); 
&lt;BR /&gt; return cal.getTime(); 
&lt;BR /&gt; } 
&lt;BR /&gt; 
&lt;BR /&gt;4/ Save your routine, then open your Job, go back to your tMap, choose the button to open the expression editor into the COLUMN you want to tranform and then choose the User Defined function "getDateMinusADay" and fill the right argument. 
&lt;BR /&gt;5/ Save your tMap and Job and execute it : it works !! 
&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;BR /&gt;Best regards;</description>
      <pubDate>Thu, 12 Aug 2010 00:05:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217830#M13264</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-12T00:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217831#M13265</link>
      <description>In perl, you can use the Date::Manip module directly in a tmap: 
&lt;BR /&gt;Date::Manip: 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133049iD780B7DE0116E4D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACJ.png" alt="0683p000009MACJ.png" /&gt;&lt;/span&gt;ateCalc($row1,"+ 6 hours")</description>
      <pubDate>Thu, 12 Aug 2010 00:20:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217831#M13265</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-08-12T00:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217832#M13266</link>
      <description>Hello,
&lt;BR /&gt;I tried to implement suggestion with java code. However the code doesn't compile. Please point out what I've done wrong.
&lt;BR /&gt;// ============================================================================
&lt;BR /&gt;//
&lt;BR /&gt;// Copyright (C) 2006-2010 Talend Inc. - 
&lt;A href="http://www.talend.com" target="_blank" rel="nofollow noopener noreferrer"&gt;www.talend.com&lt;/A&gt;
&lt;BR /&gt;//
&lt;BR /&gt;// This source code is available under agreement available at
&lt;BR /&gt;// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
&lt;BR /&gt;//
&lt;BR /&gt;// You should have received a copy of the agreement
&lt;BR /&gt;// along with this program; if not, write to Talend SA
&lt;BR /&gt;// 9 rue Pages 92150 Suresnes, France
&lt;BR /&gt;//
&lt;BR /&gt;// ============================================================================
&lt;BR /&gt;package routines;
&lt;BR /&gt;/*
&lt;BR /&gt; * user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
&lt;BR /&gt; * it must be before the "{talendTypes}" key.
&lt;BR /&gt; * 
&lt;BR /&gt; * 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
&lt;BR /&gt; * long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
&lt;BR /&gt; * Short
&lt;BR /&gt; * 
&lt;BR /&gt; * 3. {Category} define a category for the Function. it is required. its value is user-defined .
&lt;BR /&gt; * 
&lt;BR /&gt; * 4. {param} 's format is: {param} &amp;lt;type&amp;gt; &amp;lt;name&amp;gt;
&lt;BR /&gt; * 
&lt;BR /&gt; * &amp;lt;type&amp;gt; 's value should be one of: string, int, list, double, object, boolean, long, char, date. &amp;lt;name&amp;gt;'s value is the
&lt;BR /&gt; * Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
&lt;BR /&gt; * added. you can have many parameters for the Function.
&lt;BR /&gt; * 
&lt;BR /&gt; * 5. {example} gives a example for the Function. it is optional.
&lt;BR /&gt; */
&lt;BR /&gt;public class PreviousDate {
&lt;BR /&gt; /**
&lt;BR /&gt; * helloExample: not return value, only print "hello" + message.
&lt;BR /&gt; * 
&lt;BR /&gt; * 
&lt;BR /&gt; * {talendTypes} String
&lt;BR /&gt; * 
&lt;BR /&gt; * {Category} User Defined
&lt;BR /&gt; * 
&lt;BR /&gt; * {param} string("world") input: The string need to be printed.
&lt;BR /&gt; * 
&lt;BR /&gt; * {example} helloExemple("world") # hello world !.
&lt;BR /&gt; */
&lt;BR /&gt; public static void helloExample(String message) {
&lt;BR /&gt; if (message == null) {
&lt;BR /&gt; message = "World"; //$NON-NLS-1$
&lt;BR /&gt; }
&lt;BR /&gt; System.out.println("Hello " + message + " !"); //$NON-NLS-1$ //$NON-NLS-2$
&lt;BR /&gt; }
&lt;BR /&gt; private static Calendar cal = Calendar.getInstance();
&lt;BR /&gt; /**
&lt;BR /&gt; * getDateMinusADay: return the dateToChange substract ONE DAY (consistancy maintain for FEBRUARY or YEAR Change etc...)
&lt;BR /&gt; * {talendTypes} Date
&lt;BR /&gt; * {Category} User Defined
&lt;BR /&gt; * {param} Date("dateToChange") dateToTest from the source
&lt;BR /&gt; * {example} getDateMinusADay(dateToChange)
&lt;BR /&gt; */
&lt;BR /&gt; public static Date getDateMinusADay(Date dateToChange) {
&lt;BR /&gt; cal.setTime(dateToChange);
&lt;BR /&gt; cal.add(cal.DATE, -1);
&lt;BR /&gt; return cal.getTime();
&lt;BR /&gt; } 
&lt;BR /&gt;}
&lt;BR /&gt;
&lt;BR /&gt;I am getting ERROR "Calendar cannot be resolved to a type" and "Date cannot be resolved to a type"
&lt;BR /&gt;Thank you,
&lt;BR /&gt;Peter.</description>
      <pubDate>Wed, 08 Sep 2010 19:17:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217832#M13266</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-09-08T19:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217833#M13267</link>
      <description>what is the solution for the above error.i am getting the same error.please do the needful</description>
      <pubDate>Mon, 25 Nov 2013 08:44:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217833#M13267</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-25T08:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217834#M13268</link>
      <description>Hi,
&lt;BR /&gt;From what I see in your Code, you miss the import part of the JAVA Program.
&lt;BR /&gt;import java.util.Calendar;
&lt;BR /&gt;import java.util.Date;
&lt;BR /&gt;These 2 Classes are missing.
&lt;BR /&gt;Below is the CODE you should COPY/PASTE in your Routine. 
&lt;BR /&gt;(Be sure you name your Routine PreviousDate when you create it)
&lt;BR /&gt;
&lt;PRE&gt;package routines;&lt;BR /&gt;import java.util.Calendar;&lt;BR /&gt;import java.util.Date;&lt;BR /&gt;&lt;BR /&gt;/*&lt;BR /&gt;* user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but&lt;BR /&gt;* it must be before the "{talendTypes}" key.&lt;BR /&gt;*&lt;BR /&gt;* 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,&lt;BR /&gt;* long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |&lt;BR /&gt;* Short&lt;BR /&gt;*&lt;BR /&gt;* 3. {Category} define a category for the Function. it is required. its value is user-defined .&lt;BR /&gt;*&lt;BR /&gt;* 4. {param} 's format is: {param} &amp;lt;type&amp;gt; &amp;lt;name&amp;gt;&lt;BR /&gt;*&lt;BR /&gt;* &amp;lt;type&amp;gt; 's value should be one of: string, int, list, double, object, boolean, long, char, date. &amp;lt;name&amp;gt;'s value is the&lt;BR /&gt;* Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't&lt;BR /&gt;* added. you can have many parameters for the Function.&lt;BR /&gt;*&lt;BR /&gt;* 5. {example} gives a example for the Function. it is optional.&lt;BR /&gt;*/&lt;BR /&gt;public class PreviousDate {&lt;BR /&gt;    /**&lt;BR /&gt;     * helloExample: not return value, only print "hello" + message.&lt;BR /&gt;     *&lt;BR /&gt;     *&lt;BR /&gt;     * {talendTypes} String&lt;BR /&gt;     *&lt;BR /&gt;     * {Category} User Defined&lt;BR /&gt;     *&lt;BR /&gt;     * {param} string("world") input: The string need to be printed.&lt;BR /&gt;     *&lt;BR /&gt;     * {example} helloExemple("world") # hello world !.&lt;BR /&gt;     */&lt;BR /&gt;    public static void helloExample(String message) {&lt;BR /&gt;        if (message == null) {&lt;BR /&gt;            message = "World"; //$NON-NLS-1$&lt;BR /&gt;        }&lt;BR /&gt;        System.out.println("Hello " + message + " !"); //$NON-NLS-1$ //$NON-NLS-2$&lt;BR /&gt;    }&lt;BR /&gt;    private static Calendar cal = Calendar.getInstance();&lt;BR /&gt;    /**&lt;BR /&gt;     * getDateMinusADay: return the dateToChange substract ONE DAY (consistancy maintain for FEBRUARY or YEAR Change etc...)&lt;BR /&gt;     * {talendTypes} Date&lt;BR /&gt;    * {Category} User Defined&lt;BR /&gt;     * {param} Date("dateToChange") dateToTest from the source&lt;BR /&gt;     * {example} getDateMinusADay(dateToChange)&lt;BR /&gt;     */&lt;BR /&gt;    public static Date getDateMinusADay(Date dateToChange) {&lt;BR /&gt;        cal.setTime(dateToChange);&lt;BR /&gt;        cal.add(cal.DATE, -1);&lt;BR /&gt;        return cal.getTime();&lt;BR /&gt;    } &lt;BR /&gt;}&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Nov 2013 13:20:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217834#M13268</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-25T13:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract specific time interval from a given date</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217835#M13269</link>
      <description>Thanks for the reply....</description>
      <pubDate>Tue, 26 Nov 2013 10:56:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Subtract-specific-time-interval-from-a-given-date/m-p/2217835#M13269</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-11-26T10:56:48Z</dc:date>
    </item>
  </channel>
</rss>

