<?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: How to subtract time from datetime field in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310589#M81700</link>
    <description>&lt;P&gt;Hi @Darmesh Sureshbabu​,&lt;/P&gt;&lt;P&gt;I didn't quite understand what you want to achieve but here's a tip:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;you just have to play on the petterne&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqoAbAAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153282i2FC9221C10B2C8E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqoAbAAJ.png" alt="0695b00000SqoAbAAJ.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqoBKAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157375i00D444C661DFCD63/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqoBKAAZ.png" alt="0695b00000SqoBKAAZ.png" /&gt;&lt;/span&gt;     2.Using &lt;B&gt;substring(start index, end index)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqoHNAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/132258iA0C7BD40D64B2014/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqoHNAAZ.png" alt="0695b00000SqoHNAAZ.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Kind regards,&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;span class="lia-unicode-emoji" title=":face_with_medical_mask:"&gt;😷&lt;/span&gt;19&lt;/B&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2022 13:14:39 GMT</pubDate>
    <dc:creator>InfoCraft</dc:creator>
    <dc:date>2022-06-29T13:14:39Z</dc:date>
    <item>
      <title>How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310588#M81699</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have datetime field and another field has only time. i need to subtract time from date&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;eg: &lt;/P&gt;&lt;P&gt;Date : 2022-06-29 10:04:00&lt;/P&gt;&lt;P&gt;time : 00:04:00&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output : &lt;/P&gt;&lt;P&gt;2022-06-29 00:04:00.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 22:46:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310588#M81699</guid>
      <dc:creator>Darmesh</dc:creator>
      <dc:date>2024-11-15T22:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310589#M81700</link>
      <description>&lt;P&gt;Hi @Darmesh Sureshbabu​,&lt;/P&gt;&lt;P&gt;I didn't quite understand what you want to achieve but here's a tip:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;you just have to play on the petterne&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqoAbAAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153282i2FC9221C10B2C8E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqoAbAAJ.png" alt="0695b00000SqoAbAAJ.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqoBKAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157375i00D444C661DFCD63/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqoBKAAZ.png" alt="0695b00000SqoBKAAZ.png" /&gt;&lt;/span&gt;     2.Using &lt;B&gt;substring(start index, end index)&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqoHNAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/132258iA0C7BD40D64B2014/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqoHNAAZ.png" alt="0695b00000SqoHNAAZ.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Kind regards,&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;span class="lia-unicode-emoji" title=":face_with_medical_mask:"&gt;😷&lt;/span&gt;19&lt;/B&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 13:14:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310589#M81700</guid>
      <dc:creator>InfoCraft</dc:creator>
      <dc:date>2022-06-29T13:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310590#M81701</link>
      <description>&lt;P&gt;@not specified not specified​&amp;nbsp; My question is . if you see the screenshot i have given&lt;/P&gt;&lt;P&gt;i need to subtract the time with datetime field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;datetime : 2022-04-01 04:50:45&lt;/P&gt;&lt;P&gt;time : 00:04:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if i subtract 4 minutes with the datetime field. i should get 2022-04-01 04:46:45 as output.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how to achieve this in talend.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@Richard Hall​&amp;nbsp;, @Manohar B​&amp;nbsp;can you help me on this.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 13:22:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310590#M81701</guid>
      <dc:creator>Darmesh</dc:creator>
      <dc:date>2022-06-29T13:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310591#M81702</link>
      <description>&lt;P&gt;1. Try to convert date times to milliseconds (Long)&lt;/P&gt;&lt;P&gt;2.do the subtraction&lt;/P&gt;&lt;P&gt;3. Convert the result: Long ---&amp;gt; Datetime&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000SqpfQAAR.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145253i8A020CE2F1D08A00/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000SqpfQAAR.png" alt="0695b00000SqpfQAAR.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String time1 = "2022-04-01 04:50:45";&lt;/P&gt;&lt;P&gt;String time2 = "00:04:00";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");&lt;/P&gt;&lt;P&gt;SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss");&lt;/P&gt;&lt;P&gt;Date date1 = format1.parse(time1);&lt;/P&gt;&lt;P&gt;Date date2 = format2.parse(time2);&lt;/P&gt;&lt;P&gt;long difference = date1.getTime() - date2.getTime();&lt;/P&gt;&lt;P&gt;SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");&lt;/P&gt;&lt;P&gt;System.out.println(sdf.format(new Date(difference)));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Kind regards,&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;span class="lia-unicode-emoji" title=":face_with_medical_mask:"&gt;😷&lt;/span&gt;19&lt;/B&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2022 16:06:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310591#M81702</guid>
      <dc:creator>InfoCraft</dc:creator>
      <dc:date>2022-06-29T16:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310592#M81703</link>
      <description>&lt;P&gt;But Expected output is wrong in the above screenshot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output in screenshot : 2022-04-01 05:46:45&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;expected output : 2022-04-01 04:46:45&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it increases 1 hour&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 05:59:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310592#M81703</guid>
      <dc:creator>Darmesh</dc:creator>
      <dc:date>2022-06-30T05:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310593#M81704</link>
      <description>&lt;P&gt;if you want to subtract from a date you can use the &lt;A href="https://help.talend.com/r/en-US/8.0/studio-user-guide-data-integration/talenddate-routines" alt="https://help.talend.com/r/en-US/8.0/studio-user-guide-data-integration/talenddate-routines" target="_blank"&gt;addDate &lt;/A&gt;function and instead of adding you can subtract by putting minus sign in front of the number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;eg: TalendDate.addDate(row1.dateTime, -4, "mm") &lt;/B&gt;this will subtract 4 minutes from your dateTime variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You also need to slice up your subtraction time by hours/minutes/seconds to subtract each part separately. This because i'm not sure you can subtract for example &lt;B&gt;&lt;I&gt;-00:04:00 by using "hh:mm:ss"&lt;/I&gt;&lt;/B&gt; pattern but you can try it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2022 10:06:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310593#M81704</guid>
      <dc:creator>SMR040</dc:creator>
      <dc:date>2022-06-30T10:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract time from datetime field</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310594#M81705</link>
      <description>&lt;P&gt;Hi @Darmesh Sureshbabu​,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oooops it was necessary to specify that it is a duration and not the hour&lt;/P&gt;&lt;P&gt;00:04:00 (time) = midnight and four minutes&lt;/P&gt;&lt;P&gt;00:04:00 (duration) = four minutes&lt;/P&gt;&lt;P&gt;the trick is:&lt;/P&gt;&lt;P&gt;1. transform dateTime to milliseconds (Long)&lt;/P&gt;&lt;P&gt;2. transform duration in milliseconds (Long): (HH*3600 +mm*60 + ss)*1000&lt;/P&gt;&lt;P&gt;3. do the subtraction to get a long&lt;/P&gt;&lt;P&gt;4. convert Long ---&amp;gt; DateTime&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000Sr5MeAAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153974i796AE98409F98CD4/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000Sr5MeAAJ.png" alt="0695b00000Sr5MeAAJ.png" /&gt;&lt;/span&gt;&lt;B&gt;timeLong&lt;/B&gt;= ((Long.valueOf(Var.timeString.substring(0,2))*3600)+(Long.valueOf(Var.timeString.substring(2,4))*60)+(Long.valueOf(Var.timeString.substring(4,6))))*1000&lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000Sr5Q2AAJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139191i97644D68B06A415E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000Sr5Q2AAJ.png" alt="0695b00000Sr5Q2AAJ.png" /&gt;&lt;/span&gt;2nd test &lt;span class="lia-inline-image-display-wrapper" image-alt="0695b00000Sr5RPAAZ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/136448iB7E463DD35D70467/image-size/large?v=v2&amp;amp;px=999" role="button" title="0695b00000Sr5RPAAZ.png" alt="0695b00000Sr5RPAAZ.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Select as Best if its &lt;span class="lia-unicode-emoji" title=":ok_hand:"&gt;👌&lt;/span&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Kind regards,&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;span class="lia-unicode-emoji" title=":face_with_medical_mask:"&gt;😷&lt;/span&gt;19.&lt;/B&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 18:57:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-subtract-time-from-datetime-field/m-p/2310594#M81705</guid>
      <dc:creator>InfoCraft</dc:creator>
      <dc:date>2022-07-01T18:57:33Z</dc:date>
    </item>
  </channel>
</rss>

