<?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: calculate a datetime difference in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345185#M1171876</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you swuehl &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works not like this. I get no result on each line and it creates a new Table "Tabelname -1". &lt;/P&gt;&lt;P&gt;I do not understand it really...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The original Table is CaseHistory. There I do have an ID (%CaseID) to a second Table, calling Case.&lt;/P&gt;&lt;P&gt;I do get the History Values per Case inside that History Table. &lt;/P&gt;&lt;P&gt;btw I did load the Tables from a qvd File and use qualify and unqualify % to not generate syntetic keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it easier to calculate the date-diff for each step? But how can QV now the right sort order, how to tell QV which is the first entry, the second and so on?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for helping me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 8pt;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;%CaseID&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;interval&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;only&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.Field&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='status' &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.NewValue&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='closed',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.CreatedDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;BR /&gt;- &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;only&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.Field&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='created', &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.CreatedDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)),'hh:mm') &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;DateTimeDiff&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;resident&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; CaseHistory &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;group&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;%CaseID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jul 2012 11:41:03 GMT</pubDate>
    <dc:creator>beat_roos</dc:creator>
    <dc:date>2012-07-11T11:41:03Z</dc:date>
    <item>
      <title>calculate a datetime difference</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345183#M1171872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do have the following Table: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="3" cellspacing="0" class="jiveBorder" style="width: 100%; border: 1px solid #000000;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;DateTime&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;Field&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;oldValue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;TH align="center" style="background-color: #6690bc;" valign="middle"&gt;&lt;SPAN style="color: #ffffff;"&gt;&lt;STRONG&gt;newValue&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01.07.2012 - 08.04&lt;/TD&gt;&lt;TD&gt;created&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01.07.2012 - 08.15&lt;/TD&gt;&lt;TD&gt;status&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;inProgress&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02.07.2012 - 10.15&lt;/TD&gt;&lt;TD&gt;Owner&lt;/TD&gt;&lt;TD&gt;User1&lt;/TD&gt;&lt;TD&gt;User2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03.07.2012 - 14.50&lt;/TD&gt;&lt;TD&gt;status&lt;/TD&gt;&lt;TD&gt;inProgress&lt;/TD&gt;&lt;TD&gt;closed&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now I need to calculate the total time needed for the Document. I need no know the difference from the create till the status = closed. There is only one DateTime in that history table and also other status which I do not need to calculate. Just the difference from beginning to the end. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I solve that? Can anybody help me to solve that? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 10:01:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345183#M1171872</guid>
      <dc:creator>beat_roos</dc:creator>
      <dc:date>2012-07-11T10:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: calculate a datetime difference</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345184#M1171874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;DocumentID,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;interval(only(if(Field='status' and newValue='closed',DateTime)) - only(if(Field='created', DateTime)),'hh:mm') as DateTimeDiff&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;resident YOURTABLE group by DocumentID;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 10:16:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345184#M1171874</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-07-11T10:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: calculate a datetime difference</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345185#M1171876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you swuehl &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works not like this. I get no result on each line and it creates a new Table "Tabelname -1". &lt;/P&gt;&lt;P&gt;I do not understand it really...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The original Table is CaseHistory. There I do have an ID (%CaseID) to a second Table, calling Case.&lt;/P&gt;&lt;P&gt;I do get the History Values per Case inside that History Table. &lt;/P&gt;&lt;P&gt;btw I did load the Tables from a qvd File and use qualify and unqualify % to not generate syntetic keys.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it easier to calculate the date-diff for each step? But how can QV now the right sort order, how to tell QV which is the first entry, the second and so on?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot for helping me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #0000ff; font-size: 8pt;"&gt;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;STRONG style="color: #0000ff; font-size: 8pt;"&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;%CaseID&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;,&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;interval&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;only&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.Field&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='status' &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.NewValue&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='closed',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.CreatedDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;BR /&gt;- &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;only&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.Field&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;='created', &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;CaseHistory.CreatedDate&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)),'hh:mm') &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;DateTimeDiff&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;resident&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; CaseHistory &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;group&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;%CaseID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 11:41:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345185#M1171876</guid>
      <dc:creator>beat_roos</dc:creator>
      <dc:date>2012-07-11T11:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: calculate a datetime difference</title>
      <link>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345186#M1171877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I still think the approach should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to take care that your DateTime is interpreted correctly as Timestamp, e.g. by using an appropriate standard format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You table is called "Tabelname -1", because we haven't set a specific different name, so QV just follow the name pattern of the previous table. We can correct this by explicitely stating a table name:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET TimestampFormat='DD.MM.YYYY - hh.mm';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;QUALIFY *;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;UnQualify %CaseID;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CaseHistory:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD * INLINE [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%CaseID, DateTime,&amp;nbsp;&amp;nbsp;&amp;nbsp; Field,&amp;nbsp;&amp;nbsp;&amp;nbsp; oldValue,&amp;nbsp;&amp;nbsp;&amp;nbsp; newValue&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;C0815,01.07.2012 - 08.04,&amp;nbsp;&amp;nbsp;&amp;nbsp; created,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;C0815,01.07.2012 - 08.15,&amp;nbsp;&amp;nbsp;&amp;nbsp; status,&amp;nbsp;&amp;nbsp;&amp;nbsp; open,&amp;nbsp;&amp;nbsp;&amp;nbsp; inProgress&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;C0815,02.07.2012 - 10.15,&amp;nbsp;&amp;nbsp;&amp;nbsp; Owner,&amp;nbsp;&amp;nbsp;&amp;nbsp; User1,&amp;nbsp;&amp;nbsp;&amp;nbsp; User2&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;C0815,03.07.2012 - 14.50,&amp;nbsp;&amp;nbsp;&amp;nbsp; status,&amp;nbsp;&amp;nbsp;&amp;nbsp; inProgress,&amp;nbsp;&amp;nbsp;&amp;nbsp; closed&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;CaseTimeDiff:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%CaseID,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;interval(only(if(CaseHistory.Field='status' and CaseHistory.newValue='closed',CaseHistory.DateTime))&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;- only(if(CaseHistory.Field='created', CaseHistory.DateTime)),'hh:mm') as DateTimeDiff&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;resident CaseHistory group by %CaseID&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;; &lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 12:55:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/calculate-a-datetime-difference/m-p/345186#M1171877</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-07-11T12:55:42Z</dc:date>
    </item>
  </channel>
</rss>

