<?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 function converts large 6 digit numbers in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882046#M1216881</link>
    <description>&lt;P&gt;I think the more interesting question is not about QlikView interpreting&amp;nbsp;&lt;SPAN&gt;870800 as a time value but rather about your data source generating these values ...&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jan 2022 21:40:05 GMT</pubDate>
    <dc:creator>MarcoWedel</dc:creator>
    <dc:date>2022-01-17T21:40:05Z</dc:date>
    <item>
      <title>Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1881591#M1216866</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a qlikview time function where i have the following lines of code.&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;text(time(time#(TRANSMIT_TIME,'hhmmss'),'hh:mm:ss')) as TRANSMIT_TIME,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where the Transmit_time could be values like 870800 and this returns 15:08:00 , also values likes 218400 returns 22:24:00&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;can i get to know a bit more on how this time works? we are working on a similar sql function or write a stored proc if there is a calculation behind it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;can any one help me understand&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 09:02:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1881591#M1216866</guid>
      <dc:creator>venkatkp</dc:creator>
      <dc:date>2022-01-17T09:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1881772#M1216870</link>
      <description>&lt;P&gt;What is your expected output to your input respectively what's wrong with the current results?&lt;/P&gt;
&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 13:15:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1881772#M1216870</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2022-01-17T13:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882042#M1216880</link>
      <description>&lt;P&gt;Hi Marcus&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is nothing wrong with the time function in qlikview.&lt;/P&gt;
&lt;P&gt;We are trying to workout whats the logic behind converting the 6 digit number in qlik.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for ex : if you give 093513 to the field, we convert this to a number using time# and then to time with the format hh:mm:ss so the output would be 9:35:13. but i can see qlik converting&amp;nbsp; numbers like&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;870800 and this returns 15:08:00.&amp;nbsp; The same number when i try in SQL errors since the limit is only 23:59:59.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;i am trying to understand whats the time function logic behind converting this number&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;870800, i believe some calculation is applied.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 20:54:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882042#M1216880</guid>
      <dc:creator>venkatkp</dc:creator>
      <dc:date>2022-01-17T20:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882046#M1216881</link>
      <description>&lt;P&gt;I think the more interesting question is not about QlikView interpreting&amp;nbsp;&lt;SPAN&gt;870800 as a time value but rather about your data source generating these values ...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 21:40:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882046#M1216881</guid>
      <dc:creator>MarcoWedel</dc:creator>
      <dc:date>2022-01-17T21:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882051#M1216883</link>
      <description>&lt;P&gt;True. i probably need to go back and ask the mainframe teams on why such numbers are sent.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but further digging i see that after the 23:59:59 when it turns to 240000, the time starts with 00:00:00, and again when it turns to 480000 and so on...&lt;/P&gt;
&lt;P&gt;TransmitTime:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;transmit_time, City&lt;BR /&gt;870800, Melbourne&lt;BR /&gt;235959, Sydney&lt;/P&gt;
&lt;P&gt;095711, Singapore&lt;/P&gt;
&lt;P&gt;240000, Minneapolis&lt;/P&gt;
&lt;P&gt;720000, Barcelona&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;TestLoad:&lt;BR /&gt;LOAD&lt;BR /&gt;transmit_time,&lt;BR /&gt;text(time(time#(transmit_time,'hhmmss'),'hh:mm:ss')) as ActualTime,&lt;BR /&gt;City&lt;BR /&gt;Resident TransmitTime;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jan 2022 22:26:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882051#M1216883</guid>
      <dc:creator>venkatkp</dc:creator>
      <dc:date>2022-01-17T22:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882123#M1216887</link>
      <description>&lt;P&gt;Behind the converting is an interval() logic which doesn't stop by 24 hours else adding them to days + time. In your case of:&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;870800 returns 15:08:00 it means 87 / 24 = 3 (days) with a remain of 15 hours. The value itself remained here a time and not a timestamp like interval() would do - just replace time() with num() to see the numeric value behind the formatting.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Beside this I would tend to remove the outer text() because with a string you couldn't calculate ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- Marcus&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jan 2022 07:15:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882123#M1216887</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2022-01-18T07:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882586#M1216912</link>
      <description>&lt;P&gt;Thanks Marcus for the response. it helped understanding a bit. but since my requirement is to re-write, i tried my best to find a function in sql but not much luck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At times we really go hard way to get this... this is what i wrote below&lt;/P&gt;
&lt;P&gt;DECLARE @Time1 int = 730011 ;&lt;BR /&gt;--SELECT left(@Time1,1),@Time1,LEN(@Time1)&lt;BR /&gt;--select cast(substring(cast(@Time1 AS varchar),3,2) as int)&lt;BR /&gt;--Select case when len(@Time1) = 5 then STUFF(@Time1,2,2,77) else @Time1 end&lt;BR /&gt;select case when len(T1.hh) = 1 then '0'+T1.hh else T1.hh end as HH,case when len(T1.mm) = 1 then '0'+T1.mm else T1.mm end as MM ,T1.ss as SS from&lt;BR /&gt;(&lt;BR /&gt;select &lt;BR /&gt;CASE WHEN LEN(@Time1)&amp;gt;5 THEN &lt;BR /&gt;case when cast(substring(cast(@Time1 AS varchar),3,2) as int) &amp;gt; 59 &lt;BR /&gt;then &lt;BR /&gt;( ((case when (left(@Time1,2) &amp;lt; 24 ) then left(@Time1,2)&lt;BR /&gt;when (left(@Time1,2) &amp;gt; 23 and left(@Time1,2) &amp;lt; 48 ) then left(@Time1,2) % 24&lt;BR /&gt;when (left(@Time1,2) &amp;gt;= 48 and left(@Time1,2) &amp;lt; 72 ) then left(@Time1,2) % 48&lt;BR /&gt;when (left(@Time1,2) &amp;gt;= 72 and left(@Time1,2) &amp;lt; 96 ) then left(@Time1,2) % 72&lt;BR /&gt;when (left(@Time1,2) &amp;gt;= 96 and left(@Time1,2) &amp;lt; 120 ) then left(@Time1,2) % 96&lt;BR /&gt;End))+1&lt;/P&gt;
&lt;P&gt;)&lt;BR /&gt;&lt;BR /&gt;when cast(substring(cast(@Time1 AS varchar),3,2) as int) &amp;lt; 60 &lt;BR /&gt;then &lt;BR /&gt;( ((case when (left(@Time1,2) &amp;lt; 24 ) then left(@Time1,2)&lt;BR /&gt;when (left(@Time1,2) &amp;gt; 23 and left(@Time1,2) &amp;lt; 48 ) then left(@Time1,2) % 24&lt;BR /&gt;when (left(@Time1,2) &amp;gt;= 48 and left(@Time1,2) &amp;lt; 72 ) then left(@Time1,2) % 48&lt;BR /&gt;when (left(@Time1,2) &amp;gt;= 72 and left(@Time1,2) &amp;lt; 96 ) then left(@Time1,2) % 72&lt;BR /&gt;when (left(@Time1,2) &amp;gt;= 96 and left(@Time1,2) &amp;lt; 120 ) then left(@Time1,2) % 96&lt;BR /&gt;End))&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;end &lt;BR /&gt;WHEN LEN(@Time1)&amp;lt;6 THEN&lt;BR /&gt;case when cast(substring(cast(@Time1 AS varchar),2,2) as int) &amp;gt; 59 &lt;BR /&gt;then (left(@Time1,1)) +1 &lt;BR /&gt;else left(@Time1,1) end&lt;BR /&gt;END&lt;BR /&gt;as hh&lt;/P&gt;
&lt;P&gt;,(CASE WHEN LEN(@Time1)&amp;gt;5 then case &lt;BR /&gt;when cast(substring(cast(@Time1 AS varchar),3,2) as int) &amp;gt; 59 then cast(substring(cast(@Time1 AS varchar),3,2) as int) - 60 else substring(cast(@Time1 AS varchar),3,2)&lt;BR /&gt;End&lt;BR /&gt;WHEN LEN(@Time1)= 5 then case &lt;BR /&gt;when cast(substring(cast(@Time1 AS varchar),2,2) as int) &amp;gt; 59 then cast(substring(cast(@Time1 AS varchar),2,2) as int) - 60 else substring(cast(@Time1 AS varchar),2,2)&lt;BR /&gt;End END )&lt;BR /&gt;as mm&lt;/P&gt;
&lt;P&gt;,case when right(@Time1,2) = 60 then 59 else right(@Time1,2) end as ss) T1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 04:46:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882586#M1216912</guid>
      <dc:creator>venkatkp</dc:creator>
      <dc:date>2022-01-19T04:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882600#M1216915</link>
      <description>&lt;P&gt;I think this is much more complex as needed. I would try to use a function like maketime() which isn't only within Qlik available else databases like MySQL as well as MS Office provide it. Therefore I could imagine that most databases have similar functions.&lt;/P&gt;
&lt;P&gt;Even if not I wouldn't go with such large if-loops else solving it more mathematically. Here just a few ideas to extract some parts (with Qlik functions but similar ones should be also within most of the databases available):&lt;/P&gt;
&lt;P&gt;floor(floor(870800/10000)/24) = days&lt;BR /&gt;mod(floor(870800/10000),24) = hours&lt;BR /&gt;mid(870800, len(870800)-3,2) = minutes&lt;BR /&gt;right(870800, 2) = seconds&lt;/P&gt;
&lt;P&gt;and then the single parts could be added again, like:&lt;/P&gt;
&lt;P&gt;(hours / 24) + (minutes/24/60) + (seconds/24/60/60)&lt;/P&gt;
&lt;P&gt;to get a real numeric time-value which you could then format like you want.&lt;/P&gt;
&lt;P&gt;- Marcus&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 06:16:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882600#M1216915</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2022-01-19T06:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882608#M1216919</link>
      <description>&lt;P&gt;The complex in my sql query is introduced since there are conditions that we may have to handle if the minutes digits are more than 59 (ex: 876380). so here we add an hour and then reduce the minute to 3 and again add a minute and reduce sceonds to 20 (16:04:20).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 06:47:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882608#M1216919</guid>
      <dc:creator>venkatkp</dc:creator>
      <dc:date>2022-01-19T06:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Time function converts large 6 digit numbers</title>
      <link>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882615#M1216920</link>
      <description>&lt;P&gt;My example above will fetch this case, too. Just give it a trial with minute/seconds-values greater as 60, means:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(hours / 24) + (minutes/24/60) + (seconds/24/60/60)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;with&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;time((15/ 24) + (63/24/60) + (80/24/60/60))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;- Marcus&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 07:13:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Time-function-converts-large-6-digit-numbers/m-p/1882615#M1216920</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2022-01-19T07:13:33Z</dc:date>
    </item>
  </channel>
</rss>

