<?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: Time difference in decimal format. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431282#M698033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just reuse the timestamp difference (the integer part is giving the number of days):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Round(( Timestamp#(time2,'yyyymmddhhmmss') - Timestamp#(time1,'yyyymmddhhmmss')) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the number of days rounded or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;floor(( Timestamp#(time2,'yyyymmddhhmmss') - Timestamp#(time1,'yyyymmddhhmmss')) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the number of days, only full days counted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Jan 2013 15:58:01 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2013-01-17T15:58:01Z</dc:date>
    <item>
      <title>Time difference in decimal format.</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431279#M698030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two day time values within a database and want to create a decimal calculated value as a new field within my script to show the total hours in a decimal format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;time1&amp;nbsp;&amp;nbsp; 20120815153000&lt;/P&gt;&lt;P&gt;time2&amp;nbsp;&amp;nbsp; 20120815070000&lt;/P&gt;&lt;P&gt;Format:YYYYMMDDHHMMSS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within this example my end time is 15h30 and my starting time is 07h30. I would like to have an integer value of 8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A second attempt would be to also use the amount of day's:&lt;/P&gt;&lt;TABLE height="21" style="width: 665px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;(Left(Dte,8) - Left(Dts,8) + 1) * ((Dte - Dts)/100) &lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt; AS IZ.TotaalHours,&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This works except for the hour part. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 14:19:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431279#M698030</guid>
      <dc:creator>andries_bos</dc:creator>
      <dc:date>2013-01-17T14:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference in decimal format.</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431280#M698031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, inteprete your datetime values correctly using e.g. timestamp#() function.&lt;/P&gt;&lt;P&gt;Then you can calculate your time difference using interval() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD *,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num#(Interval(time1-time2,'h')) as DurationHours;&lt;/P&gt;&lt;P&gt;LOAD timestamp(Timestamp#(time1,'YYYYMMDDhhmmss')) as time1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp(Timestamp#(time2,'YYYYMMDDhhmmss')) as time2&lt;/P&gt;&lt;P&gt; INLINE [&lt;/P&gt;&lt;P&gt;time1, time2&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;20120815153000,20120815070000&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 14:35:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431280#M698031</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-01-17T14:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference in decimal format.</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431281#M698032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually managed to solve my problem in a rather easy way with your suggested timestamp:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This could be done within the original scripting without an extra load.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Round(( Timestamp#(time2,'yyyymmddhhmmss') - Timestamp#(time1,'yyyymmddhhmmss')) * 24, 0.1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will format my times, will subtract them and convert them into a number: multiplication with 24 will effectly resolve it into a needed decimal number. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As these are quite large numbers, the round function for this example will round the results into the needed 8,5 hours. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A second stage could be to calculate the amount of days. using ony the 8 left characters and multiply this with the hours / day. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 15:48:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431281#M698032</guid>
      <dc:creator>andries_bos</dc:creator>
      <dc:date>2013-01-17T15:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference in decimal format.</title>
      <link>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431282#M698033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just reuse the timestamp difference (the integer part is giving the number of days):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Round(( Timestamp#(time2,'yyyymmddhhmmss') - Timestamp#(time1,'yyyymmddhhmmss')) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the number of days rounded or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;floor(( Timestamp#(time2,'yyyymmddhhmmss') - Timestamp#(time1,'yyyymmddhhmmss')) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to get the number of days, only full days counted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2013 15:58:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-difference-in-decimal-format/m-p/431282#M698033</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-01-17T15:58:01Z</dc:date>
    </item>
  </channel>
</rss>

