<?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: Date Calculation in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348809#M129216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ronny123,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if I understood correctly, if you start after 1 pm, your production process will span at least 2 days (max. 4 hours the first day, then full next working day, and rest of the work on the day after). This complicates the things a bit, because you need to check for weekend / holiday twice, and the second check is depending on the outcome of the first check (for example, if you start on friday, you're check will result in next working day is Monday, but then you need to check if the day after Monday is a holiday or not).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can expand my last example to do this, using a nested peek() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, since you only have working hours nine to five, the final calculation is also a little bit more complicated, but I think the attached should get what I understood you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice weekend,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Apr 2012 21:48:04 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2012-04-27T21:48:04Z</dc:date>
    <item>
      <title>Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348805#M129212</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 have a process which takes 12 hrs to complete from the start date time. So i have start&amp;nbsp; timestamps for different process id's&amp;nbsp; and i want to calculate the time stamp when they will be completed based on 12hrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But i dont have to consider weekends and holidays if they fall in between&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for eg. if the start date time is 12/04/2012 10:00:00&amp;nbsp; and 13th is a holiday then i dont have to consider 13 and also 14 and 15 as they are weekends.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 08:33:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348805#M129212</guid>
      <dc:creator />
      <dc:date>2012-04-12T08:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348806#M129213</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;Try the networkdays function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;::&lt;/P&gt;&lt;P class="syntax"&gt;&lt;A name="kanchor521"&gt;&lt;/A&gt;&lt;A name="networkdays"&gt;&lt;/A&gt;&lt;SPAN class="Bold"&gt;networkdays (&lt;/SPAN&gt;&lt;SPAN class="Italic"&gt;start:date, end_date {, holiday}&lt;/SPAN&gt;&lt;SPAN class="Bold"&gt;)&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Returns the number of working days (Monday-Friday) between and including &lt;SPAN class="Italic"&gt;start_date&lt;/SPAN&gt; and &lt;SPAN class="Italic"&gt;end_date&lt;/SPAN&gt; taking into account any optionally listed &lt;SPAN class="Italic"&gt;holidays&lt;/SPAN&gt;. All parameters should be valid dates or timestamps. &lt;/P&gt;&lt;P&gt;::&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As a startdate you could use the actual startdate, as a enddate you could use the floor(startdate+12h).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 14:37:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348806#M129213</guid>
      <dc:creator />
      <dc:date>2012-04-12T14:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348807#M129214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it's the other way round, ronny123 knows the interval, but wants to get the end date / end timestamp back.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would first create a calendar with all days, and include also a flag for holidays. Then I would try calculating the number of holidays or week end days to follow directly on any given date for all dates. You can do this by sorting the calendar in reverse order and then use peek() to check for a non-working day and also for accumulating the non-working days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then it's all about some logic to add these calculated non-working days on top of your time calculation for your end timestamp:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TMPCalendar:&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;date(makedate(2012)+recno()-1) as Date&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;AutoGenerate 125;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;left join LOAD * INLINE [&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Date, Holiday&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;'06.01.2012', Epiphany&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;'06.04.2012', 'Good Friday'&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;'09.04.2012', 'Easter Monday'&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;/P&gt;&lt;P&gt;&lt;EM&gt;Calendar:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD *, if(not isnull(Start), timestamp(rangesum(Start,if(hour(Start)&amp;gt;11,AddDay),interval#('12:00:00'))))as End;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;LOAD *, WeekDay(Date) as Weekday, Month(Date) as Month, Year(Date) as Year, if(weekday(Date)&amp;lt;5 and isnull(Holiday), Timestamp(Date+RAND())) as Start;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;load *, if(weekday(peek(Date))&amp;gt;=5 or not isnull(peek(Holiday)), rangesum(peek(AddDay),1)) as AddDay Resident TMPCalendar order by Date desc;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;drop table TMPCalendar;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would need to replace the 12:00:00 resp. 11 with your process duration time resp. the hour of the day that allows the process still to finish on the same day&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 15:17:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348807#M129214</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-04-12T15:17:14Z</dc:date>
    </item>
    <item>
      <title>Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348808#M129215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi! Stefan the solution provided by you helped a lot.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have more condition that working productive&amp;nbsp; hour are only from&amp;nbsp; 9AM&amp;nbsp; to 5 PM . So what happens is my 12 hr (the ideal time to complete the process) completes on next day, but if&amp;nbsp; weekend of or a holiday falls in between, the end date might be some&amp;nbsp; other day than the next day&amp;nbsp; as hours in&amp;nbsp; weekends and holidays will not be considered as productive hours.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So i&amp;nbsp; am not getting the way to by pass the non productive hours of&amp;nbsp;&amp;nbsp; holidays and weekends and calculate the end date from the start date based on 12 hrs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;urgent help required&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls let me know in case you need some more clarification.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Apr 2012 08:25:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348808#M129215</guid>
      <dc:creator />
      <dc:date>2012-04-26T08:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348809#M129216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ronny123,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if I understood correctly, if you start after 1 pm, your production process will span at least 2 days (max. 4 hours the first day, then full next working day, and rest of the work on the day after). This complicates the things a bit, because you need to check for weekend / holiday twice, and the second check is depending on the outcome of the first check (for example, if you start on friday, you're check will result in next working day is Monday, but then you need to check if the day after Monday is a holiday or not).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can expand my last example to do this, using a nested peek() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, since you only have working hours nine to five, the final calculation is also a little bit more complicated, but I think the attached should get what I understood you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a nice weekend,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Apr 2012 21:48:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348809#M129216</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-04-27T21:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348810#M129217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi! stefan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the reply, gr8 help provided by you.&lt;/P&gt;&lt;P&gt;one thing i want to mention is , actually&amp;nbsp; end date in the application sent&amp;nbsp; is not comming aginst the weekends. tickets also come in the system on weekends also but work start on them only on monday after 9 am.so end date is also needed for those cases also. As those cases will also be having a due date time when ideally the work on them should be completed.&lt;/P&gt;&lt;P&gt;in the application attached i am sending the date time when the ticket has come in the system which you can use as a start date in the application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2012 13:23:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348810#M129217</guid>
      <dc:creator />
      <dc:date>2012-05-01T13:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348811#M129218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ronny123, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what do you mean with '&lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #eef4f9;"&gt;end date in the application sent&amp;nbsp; is not comming aginst the weekends.'&lt;/SPAN&gt;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you give some examples of your expected end date for ticket timestamps e.g. on a saturday morning (before 9 am)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: I assumed that your tickets come in any time, but the work starts only in productive period (working day 9 to 5) and the ideal end time is calculated on top of the next possible start timestamp. See attached (I generalized my first sample app that there can be now unlimited tickets per day, and that first the next possible start timestamp is calculated, and then the ideal end time).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #636363; font-family: Arial; font-size: 12px; background-color: #eef4f9;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 21:44:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348811#M129218</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2012-05-04T21:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Date Calculation</title>
      <link>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348812#M129219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi! stefan.&lt;/P&gt;&lt;P&gt;thanks a lot for your help and support, the logic provided by you helped a lot. I analysed different&amp;nbsp; permutations and combinations which can exist and used ﻿LastWorkDay functions to calulate the end date and finally created a logic which is working fine..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again..:) tc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2012 07:26:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Date-Calculation/m-p/348812#M129219</guid>
      <dc:creator />
      <dc:date>2012-05-14T07:26:50Z</dc:date>
    </item>
  </channel>
</rss>

