<?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: Count the number of saturdays &amp; sundays between two dates in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468039#M174777</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 Following Expression,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;if (weekday(yourdatefield)='Sat' or weekday(yourdatefield)='Sun' , 1, 0)&amp;nbsp; AS Weekendflag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=sum({1&amp;lt; &lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Weekendflag&lt;/SPAN&gt;={1} ,CalendarDate={"&amp;gt;=$(=date#('16-03-2013','DD-MM-YYYY'))&amp;lt;=$(=Date#('31-10-2014','DD-MM-YYYY'))"}&amp;gt;}Weekendflag)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Nirav Bhimani&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Mar 2013 09:23:51 GMT</pubDate>
    <dc:creator>nirav_bhimani</dc:creator>
    <dc:date>2013-03-22T09:23:51Z</dc:date>
    <item>
      <title>Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468034#M174772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've a small issue here. I'm calculating the count of saturdays and sundays between two dates. I've generated master calendar iun my qvw. I used the following expression to calculate the desired:&lt;/P&gt;&lt;P&gt;=count({1&amp;lt;CalendarWeek={Sat,Sun},CalendarDate={"&amp;gt;=$(=Date#('16-03-2013','DD-MM-YYYY'))&amp;lt;=$(=Date#('31-10-2014','DD-MM-YYYY'))"}&amp;gt;}CalendarDate)&lt;/P&gt;&lt;P&gt;which is returning zero.&lt;/P&gt;&lt;P&gt;Also I've used the expression =Count({1&amp;lt;CalendarDate={"&amp;lt;=$(=date#('31/10/2014','DD/MM/YYYY'))&amp;gt;=$(=date#('16/03/2013','DD/MM/YYYY'))"}&amp;gt;}CalendarMonth)&lt;/P&gt;&lt;P&gt;to calculate the number of months between two dates, which is returning 595(no way near the result.&lt;/P&gt;&lt;P&gt;can you guys let me know where I'm going wrong. I've attached my qvw as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;Surendra&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:09:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468034#M174772</guid>
      <dc:creator />
      <dc:date>2013-03-22T08:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468035#M174773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your second expression would count the number of days between the dates. There is apparently one CalendarMonth value for each date so 31 times Jan for january etc.&lt;/P&gt;&lt;P&gt;I would suggest creating a flag in your calendar where you flag all Saturdays and Sundays as 1 under a field called WeekendFlag for example. Then you can just sum up the field WeekendFlag for your date range.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:30:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468035#M174773</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-22T08:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468036#M174774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes Johannes is correct,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can do it by using this expression &lt;/P&gt;&lt;P&gt;in&amp;nbsp; load script.&lt;/P&gt;&lt;P&gt;if (weekday(yourdatefield)='Sat' or weekday(yourdatefield)='Sun' , 'A')&amp;nbsp; AS Weekendflag&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then use this expression count(Weekendflag)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;anant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:38:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468036#M174774</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-03-22T08:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468037#M174775</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 this Expression &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=count({1&amp;lt;CalendarWeek={'Sat','Sun'},CalendarDate={"&amp;gt;=$(=Date#('01-01-2000','DD/MM/YYYY'))&amp;lt;=$(=Date#('31/01/2000','DD-MM-YYYY'))"}&amp;gt;}CalendarDate)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It will display correct result for that month.&lt;/P&gt;&lt;P&gt;Now replace those date with your date .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Nirav Bhimani&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:42:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468037#M174775</guid>
      <dc:creator>nirav_bhimani</dc:creator>
      <dc:date>2013-03-22T08:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468038#M174776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your quick response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Johannes,&lt;A _jive_internal="true" class="jiveTT-hover-user jive-username-link" href="https://community.qlik.com/people/anantmaxx" id="jive-9713117321574750707304" style="background-color: #ffffff; font-size: 12px; color: #007fc0; font-weight: bold; font-family: Arial; text-align: center;"&gt;anantmaxx&lt;/A&gt; :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've created the weekend flag as you said. But when I use the expression:&lt;/P&gt;&lt;P&gt;=sum({1&amp;lt;CalendarDate={"&amp;gt;=$(=date#('16-03-2013','DD-MM-YYYY'))&amp;lt;=$(=Date#('31-10-2014','DD-MM-YYYY'))"}&amp;gt;}Weekendflag) in the front end it's not working. There is no error in the script and the 'Weekendflag' field is displaying 1 for all saturdays and sundays.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Nirav:&lt;/P&gt;&lt;P&gt;It's working absolutely fine with date range you've taken.But when I enter my date fields it's displaying wrong value.&lt;/P&gt;&lt;P&gt;=count({1&amp;lt;CalendarWeek={'Sat','Sun'},CalendarDate={"&amp;gt;=$(=Date#('01-01-2013','DD/MM/YYYY'))&amp;lt;=$(=Date#('31/12/2014','DD-MM-YYYY'))"}&amp;gt;}CalendarDate).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems like a problem with date interpretation&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/confused.png" /&gt;.&lt;/P&gt;&lt;P&gt;Because when I enter year range instead of date range , it's showing correct result for the above expressions , we've discussed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:59:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468038#M174776</guid>
      <dc:creator />
      <dc:date>2013-03-22T08:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468039#M174777</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 Following Expression,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;if (weekday(yourdatefield)='Sat' or weekday(yourdatefield)='Sun' , 1, 0)&amp;nbsp; AS Weekendflag&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;=sum({1&amp;lt; &lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Weekendflag&lt;/SPAN&gt;={1} ,CalendarDate={"&amp;gt;=$(=date#('16-03-2013','DD-MM-YYYY'))&amp;lt;=$(=Date#('31-10-2014','DD-MM-YYYY'))"}&amp;gt;}Weekendflag)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt;Nirav Bhimani&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:23:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468039#M174777</guid>
      <dc:creator>nirav_bhimani</dc:creator>
      <dc:date>2013-03-22T09:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468040#M174778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nirav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That is returning zero.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:27:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468040#M174778</guid>
      <dc:creator />
      <dc:date>2013-03-22T09:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Count the number of saturdays &amp; sundays between two dates</title>
      <link>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468041#M174779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try the following Formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Following will give you count of all Mondays&lt;/P&gt;&lt;P&gt;sum(&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(&lt;/P&gt;&lt;P&gt;&amp;nbsp; mod((leaveTo-leaveFrom),7)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;gt;=&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(&lt;/P&gt;&lt;P&gt;&amp;nbsp; (weekday(leaveTo)-/* Change for day of week */0)&amp;lt;0,&lt;/P&gt;&lt;P&gt;&amp;nbsp; weekday(leaveTo)-/* Change for day of week */0+7,&lt;/P&gt;&lt;P&gt;&amp;nbsp; weekday(leaveTo)-/* Change for day of week */0)&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,floor((leaveTo-leaveFrom)/7)+1&lt;/P&gt;&lt;P&gt;&amp;nbsp; ,floor((leaveTo-leaveFrom)/7))&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Nov 2014 02:41:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Count-the-number-of-saturdays-sundays-between-two-dates/m-p/468041#M174779</guid>
      <dc:creator />
      <dc:date>2014-11-07T02:41:08Z</dc:date>
    </item>
  </channel>
</rss>

