<?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: Difference between 2 dates in Hours in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221240#M872455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;interval( enddate - startdate , 'HH' )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anand&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Nov 2016 10:57:31 GMT</pubDate>
    <dc:creator>its_anandrjs</dc:creator>
    <dc:date>2016-11-09T10:57:31Z</dc:date>
    <item>
      <title>Difference between 2 dates in Hours</title>
      <link>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221239#M872454</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 2 date fields startdate,enddate with timestamps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now i want to find out the difference between those 2 dates in terms of number of hours.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to get this ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221239#M872454</guid>
      <dc:creator>mohan2391</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between 2 dates in Hours</title>
      <link>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221240#M872455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this way&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;interval( enddate - startdate , 'HH' )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anand&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 10:57:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221240#M872455</guid>
      <dc:creator>its_anandrjs</dc:creator>
      <dc:date>2016-11-09T10:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between 2 dates in Hours</title>
      <link>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221241#M872456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;May be like this ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;STRONG&gt;Hour&lt;/STRONG&gt;(startdate) - &lt;STRONG&gt;Hour&lt;/STRONG&gt;(enddate) as Diff_Hours&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;I hope this might helps you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;-Nagarjun&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 11:04:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221241#M872456</guid>
      <dc:creator>nagarjuna_kotha</dc:creator>
      <dc:date>2016-11-09T11:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between 2 dates in Hours</title>
      <link>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221242#M872457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mohan Krishna,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//All calculations are based on the decimal representation of date and time&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set vStartTime = .375; //9:00am&lt;/P&gt;&lt;P&gt;Set vCloseTime = .708333333334; // 5:00PM&lt;/P&gt;&lt;P&gt;Set vFullDay = .333333334; // 8 hours - full day&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FirstPass:&lt;/P&gt;&lt;P&gt;LOAD CloseDateTime, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; StartDateTime,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;// calculate total hours worked excluding the Start Day and the Close Day&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;NetWorkDays(StartDateTime+1,CloseDateTime-1) * 8 as HoursWorked,&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//calculates the decimal number for hours after the Start time up to a maximum full days work (9:00am to 5:00pm)&lt;/P&gt;&lt;P&gt;IF(num#(Time#(Frac(StartDateTime),'hh:mm'))&amp;gt;num#($(vStartTime)) and&amp;nbsp; num#(Time#(Frac(StartDateTime),'hh:mm'))&amp;gt;num#($(vCloseTime)) ,0,if(num#(Time#(Frac(StartDateTime),'hh:mm'))&amp;gt;num#($(vStartTime)),num#($(vCloseTime))-num#(Time#(Frac(StartDateTime),'hh:mm')),num#($(vFullDay))))as StartDayTime,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//calculates the decimal number for hours before the Close time up to a maximum full days work (9:00am to 5:00pm)&lt;/P&gt;&lt;P&gt;IF(num#(Time#(Frac(CloseDateTime),'hh:mm'))&amp;gt;num#($(vStartTime)) and&amp;nbsp; num#(Time#(Frac(CloseDateTime),'hh:mm'))&amp;gt;num#($(vCloseTime)) ,num#($(vFullDay)),if(num#(Time#(Frac(CloseDateTime),'hh:mm'))&amp;gt;num#($(vStartTime)),-num#($(vStartTime))+num#(Time#(Frac(CloseDateTime),'hh:mm')),0))as CloseDayTime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;C:\Users\Jarvis\Downloads\NetHoursStartDateCloseDateandTime.xls&lt;/P&gt;&lt;P&gt;(biff, embedded labels, table is Sheet2$);&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;/P&gt;&lt;P&gt;New:&lt;/P&gt;&lt;P&gt;load&lt;/P&gt;&lt;P&gt;StartDateTime,&lt;/P&gt;&lt;P&gt;CloseDateTime, &lt;/P&gt;&lt;P&gt;HoursWorked,&lt;/P&gt;&lt;P&gt;//We now have 'HoursWorked' which excludes the Start Day and Close Day &lt;/P&gt;&lt;P&gt;//the script below calculates the hrs and mins for those two days&lt;/P&gt;&lt;P&gt;//The first part calculates hrs and min when the start date and close date are the same day&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//If the day is Sat or Sun then 0 hours&lt;/P&gt;&lt;P&gt;if(num#(NetWorkDays(StartDateTime,StartDateTime)) = 0 and num#(NetWorkDays(CloseDateTime,CloseDateTime)) = 0,0,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//test if the Start date and Close date are the same&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(Date(floor(StartDateTime)) = Date(floor(CloseDateTime)), &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// test to see if the Start time is before 9:00am&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(StartDayTime&amp;nbsp; = num#($(vFullDay)), &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;//get the hours and minutes up to the close time&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Floor(CloseDayTime * 24) &amp;amp; ' Hrs ' &amp;amp; Floor(Frac(CloseDayTime * 24)* 60) &amp;amp; ' Min', &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt; // test to see if the Close time is after 5:00pm&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; if(CloseDayTime&amp;nbsp; = num#($(vFullDay)), &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt; //get the hours and minutes for the Start day time&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Floor(StartDayTime * 24) &amp;amp; ' Hrs ' &amp;amp; Floor(Frac(StartDayTime * 24)* 60) &amp;amp; ' Min', &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; //If the start time is after 8:00am and close time if before 5:00pm calcuate the hours and minutes&lt;/P&gt;&lt;P&gt;&amp;nbsp; Floor(StartDayTime * 24) + Floor(CloseDayTime * 24)-8 + (Floor((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)) &amp;amp; ' Hrs ' &amp;amp; Frac((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)*60&amp;nbsp; &amp;amp; ' Min')),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//now calculate hrs and mins when the start date and close date are different days&lt;/P&gt;&lt;P&gt;//if the Start date is Sat or Sun then 0 hrs&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(num#(NetWorkDays(StartDateTime,StartDateTime)) = 0,0, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//get the Start time &lt;/P&gt;&lt;P&gt;&amp;nbsp; Floor(StartDayTime * 24))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;//add to the start time the close time &lt;/P&gt;&lt;P&gt;//if the close date is Sat or Sun then hours are zero (0)&lt;/P&gt;&lt;P&gt;&amp;nbsp; +if(num#(NetWorkDays(CloseDateTime,CloseDateTime)) = 0,0,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//calculate the close time hours taking into account the adding start minutes and end minutes can add up to 1 hour &lt;/P&gt;&lt;P&gt;&amp;nbsp; Floor(CloseDayTime * 24)) + HoursWorked+ (Floor((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)) &amp;amp; ' Hrs&amp;nbsp; ' &amp;amp; Frac((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)*60&amp;nbsp; &amp;amp; ' Min')) &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; as FinalHours,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// below are some mid calculations that needed to be incorporated in the final answer above&lt;/P&gt;&lt;P&gt;NetWorkDays(StartDateTime,StartDateTime) as StartSatSun,&lt;/P&gt;&lt;P&gt;if(num#(NetWorkDays(StartDateTime,StartDateTime)) = 0,0,Floor(StartDayTime * 24))as SHours, // 0 if the date is a holiday&lt;/P&gt;&lt;P&gt;if(num#(NetWorkDays(CloseDateTime,CloseDateTime)) = 0,0,Floor(CloseDayTime * 24))as CHours, // 0 if the date is a holiday&lt;/P&gt;&lt;P&gt;if(num#(NetWorkDays(StartDateTime,StartDateTime)) = 0,0,Floor(StartDayTime * 24))+if(num#(NetWorkDays(CloseDateTime,CloseDateTime)) = 0,0,Floor(CloseDayTime * 24)) + HoursWorked as SCHours,&lt;/P&gt;&lt;P&gt;(Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60&amp;nbsp; as SCMinutes,&lt;/P&gt;&lt;P&gt;Floor((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)&amp;nbsp; as HrsIfMinutesSandCTotalOver1Hour,&lt;/P&gt;&lt;P&gt;Frac((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)*60&amp;nbsp;&amp;nbsp; as remMinute,&lt;/P&gt;&lt;P&gt;if(num#(NetWorkDays(StartDateTime,StartDateTime)) = 0,0,Floor(StartDayTime * 24))+if(num#(NetWorkDays(CloseDateTime,CloseDateTime)) = 0,0,Floor(CloseDayTime * 24)) + HoursWorked+ (Floor((Floor(Frac(StartDayTime * 24)* 60) + Floor(Frac(CloseDayTime * 24)* 60)) / 60)) as SCHoursFinal,&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;/P&gt;&lt;P&gt;NetWorkDays(CloseDateTime,CloseDateTime) as CloseSatSun,&lt;/P&gt;&lt;P&gt;Floor(CloseDayTime * 24)&amp;nbsp; as CloseHours,&lt;/P&gt;&lt;P&gt;Floor(Frac(CloseDayTime * 24)* 60)&amp;nbsp; as CloseMinutes,&lt;/P&gt;&lt;P&gt;Frac(CloseDayTime * 24*60 )*60&amp;nbsp; as CloseSecconds,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(StartDayTime * 24)&amp;nbsp; as StartFirst,&lt;/P&gt;&lt;P&gt;Floor(StartDayTime * 24)&amp;nbsp; as StartHours,&lt;/P&gt;&lt;P&gt;Floor(Frac(StartDayTime * 24)* 60)&amp;nbsp; as StartMinutes,&lt;/P&gt;&lt;P&gt;Frac(StartDayTime * 24*60 )*60&amp;nbsp; as StartSecconds&lt;/P&gt;&lt;P&gt;Resident FirstPass;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Hemanth&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 11:27:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221242#M872457</guid>
      <dc:creator>hemanthaanichet</dc:creator>
      <dc:date>2016-11-09T11:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between 2 dates in Hours</title>
      <link>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221243#M872458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;use the below query to find the duration time between the two dates&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt; font-family: courier new,courier;"&gt;=time((Time('End date','HH:MM' &lt;SPAN style="color: #ff6600;"&gt;define format&lt;/SPAN&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt; font-family: courier new,courier;"&gt;-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 14pt; font-family: courier new,courier;"&gt;(Time('Start Date','HH:MM'&amp;nbsp; &lt;SPAN style="color: #ff6600;"&gt;define format&lt;/SPAN&gt; ) ),'HH')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-size: 10pt; font-family: arial,helvetica,sans-serif;"&gt;hope this helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2016 11:33:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Difference-between-2-dates-in-Hours/m-p/1221243#M872458</guid>
      <dc:creator>eromiyasimon</dc:creator>
      <dc:date>2016-11-09T11:33:39Z</dc:date>
    </item>
  </channel>
</rss>

