<?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: Week and weekname functions giving different results in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721466#M54882</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you once again for the replies. My requirement is to match the app's Year-Week field with Outlook's default settings (at least in our region). This is what Outlook is set to:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Outlook.png" style="width: 632px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36126iDF9E443E9EC0BE76/image-size/large?v=v2&amp;amp;px=999" role="button" title="Outlook.png" alt="Outlook.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have set the script variables to the following:&lt;/P&gt;&lt;P&gt;SET FirstWeekDay=6; -&amp;gt; I want the first&amp;nbsp; day of the week to be Sunday&lt;BR /&gt;SET BrokenWeeks= 0; -&amp;gt; It seems like Outlook doesn't use broken weeks&lt;BR /&gt;SET ReferenceDay=1; -&amp;gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;, thanks for pointing this out. When I looked at Dec 1997 and Jan 1998 I realised that setting this to four is the equivalent of the First 4-day week option in the Outlook calendar:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Four day week in Outlook.png" style="width: 228px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36127iFBEB765A1E4A0232/image-size/large?v=v2&amp;amp;px=999" role="button" title="Four day week in Outlook.png" alt="Four day week in Outlook.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By using the variables above, I am able to get a perfect match to Outlook using the Week function. However, the weekname function remains off by 1 week for the most part and 2 weeks when looking at 1994/12/28 - 1994/12/31.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Qlik_vs_Outlook.png" style="width: 825px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36129i4FB2D1C2A781F976/image-size/large?v=v2&amp;amp;px=999" role="button" title="Qlik_vs_Outlook.png" alt="Qlik_vs_Outlook.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The reason why I am asking all of these questions is because I have added a Year-Week dimension to our autocalendar script and I used weekname() for the function as it returns a dual which is nice for calculations where the year is relevant too. The question I have now is whether I should rather build a function using Dual(Year(TestDate)&amp;amp;'/'&amp;amp;Num(Week(TestDate),'00'),WeekStart(TestDate)) or whether there is something I am missing with the built in weekname function which is returning the wrong week. I feel like the custom function will work better, but I also don't want to use a workaround if there is a flaw in my understanding or configuration.&lt;/P&gt;&lt;P&gt;Here is the script I used for the table above (and I also included the custom function I mentioned above):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET FirstWeekDay=6;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SET BrokenWeeks= 0;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SET ReferenceDay=1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TestDates:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Usecase,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;TestDate,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Week(TestDate),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Weekname(TestDate),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Dual(Year(TestDate)&amp;amp;'/'&amp;amp;Num(Week(TestDate),'00'),WeekStart(TestDate)),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Date(TestDate,'WWWW')&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INLINE [&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Usecase,TestDate&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/28&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/29&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/30&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/31&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/01&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/02&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/03&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/04&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/05&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/06&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/07&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/08&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/09&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/10&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/11&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/28&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/29&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/30&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/31&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/01&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/02&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/03&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/04&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/05&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/06&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/07&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/08&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/09&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/10&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/11&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thanks again for all the helpful input, I really appreciate it.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jun 2020 21:19:07 GMT</pubDate>
    <dc:creator>Mauritz_SA</dc:creator>
    <dc:date>2020-06-23T21:19:07Z</dc:date>
    <item>
      <title>Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1718709#M54604</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I am using the &lt;A href="https://help.qlik.com/en-US/sense/April2020/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeFunctions/weekname.htm" target="_self"&gt;weekname&lt;/A&gt; function to get a combination of the year and the week from a date. However, the resultant week returned by the weekname function is one week behind the week function. I assume the weekname result is wrong. Below is what I mean:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Qlik Sense example" style="width: 403px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35536i3DD0108DA5A9C3B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="week_and_weekname.png" alt="Qlik Sense example" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Qlik Sense example&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The date in the above screenshot is actually the same as in the help file's example (which returns 2013/02 when they do it (which is what I want)):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Help file" style="width: 641px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35537iA223154CDAEE3DA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Weekname_help_file.png" alt="Help file" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Help file&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;We don't change any of the initial variables that are used for calendars and I would expect the Week and Weekname functions to be affected by it the same way anyways.&lt;/P&gt;&lt;P&gt;I'm not sure if anyone has experienced the same thing or if you can let me know whether you get different results. I would like to see if it is something related to Qlik or whether it is related to our setup.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/25001"&gt;@Vegar&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 07:53:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1718709#M54604</guid>
      <dc:creator>Mauritz_SA</dc:creator>
      <dc:date>2020-06-15T07:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1718785#M54607</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/31029"&gt;@Mauritz_SA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I hope this is useful for you&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Check&amp;nbsp; the date format in environment&amp;nbsp; variables in initial script editor tab based on the input you give&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;if you give the input like&amp;nbsp; weekname('2013/01/12')&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SET&lt;/FONT&gt; &lt;FONT color="#FF00FF"&gt;DateFormat&lt;/FONT&gt;='YYYY/MM/DD';&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;if you give the input like&amp;nbsp; weekname('01/12/2013')&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;SET&lt;/FONT&gt; &lt;FONT color="#FF00FF"&gt;DateFormat&lt;/FONT&gt;='MM/DD/YYYY';&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT color="#000000"&gt;if you give the input like&amp;nbsp; weekname('12/01/2013')&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SET&lt;/FONT&gt; &lt;FONT color="#FF00FF"&gt;DateFormat&lt;/FONT&gt;='DD/MM/YYYY';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="raji6763_1-1592218702633.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35554iAE75F83ED0D23DD4/image-size/large?v=v2&amp;amp;px=999" role="button" title="raji6763_1-1592218702633.png" alt="raji6763_1-1592218702633.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it's working for me.here is the output i got&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="raji6763_0-1592218574773.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35553i0199E8241C7E997E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="raji6763_0-1592218574773.png" alt="raji6763_0-1592218574773.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;raji&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 11:09:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1718785#M54607</guid>
      <dc:creator>raji6763</dc:creator>
      <dc:date>2020-06-15T11:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1718862#M54613</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/31029"&gt;@Mauritz_SA&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The issue seems to be with how the default values of parameter&amp;nbsp;&lt;STRONG&gt;&lt;SPAN class="statement"&gt;first_week_day&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="statement"&gt;are taken in these functions.&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class="statement"&gt;WeekDay() - default value would be taken from the script variable&amp;nbsp;&lt;STRONG&gt;FirstWeekDay&amp;nbsp;&lt;/STRONG&gt;, however&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="statement"&gt;Week() - default value is Monday [ 0=(Monday)]&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;That is where the issue is. If you set your&amp;nbsp;&lt;SPAN class="statement"&gt;&lt;STRONG&gt;FirstWeekDay&lt;/STRONG&gt; value to 0 (i.e- equivalent to Monday)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="statement"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 155px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35572iD865474FD769526A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;your problem should go away.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:05:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1718862#M54613</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2020-06-15T14:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1719542#M54681</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/11742"&gt;@raji6763&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you both for your replies.&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;, I am not sure if that is the issue. Below is what I have in script:&lt;/P&gt;&lt;P&gt;SET FirstWeekDay=6;&lt;BR /&gt;SET BrokenWeeks=1;&lt;BR /&gt;SET ReferenceDay=0;&lt;/P&gt;&lt;P&gt;However, below is a table of week and weekname functions:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dates.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35705iAA63878ADA19DD6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dates.png" alt="Dates.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I find strange is that the default Week and Weekname functions are exactly one week apart (so I don't think the FirstWeekDay is the issue). It is almost as if Weekname takes the first full week (unbroken week) as its first week. Unfortunately I tested that and found that I get the following and now I am convinced that there is something wrong with my weekname function as it shows that 1995/01/01-1995/01/07 is 1994/52:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dates2.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35706i4825F9453ECE2B29/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dates2.png" alt="Dates2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have only used the default settings in QSD June 2019 (although the same is happening on the server which is April 2019). Below is the script I used:&lt;/P&gt;&lt;P&gt;TestDates:&lt;BR /&gt;LOAD TestDate,&lt;BR /&gt;Week(TestDate),&lt;BR /&gt;Weekname(TestDate),&lt;BR /&gt;Week(TestDate,6,1,0),&lt;BR /&gt;Weekname(TestDate,0,6),&lt;BR /&gt;Date(TestDate,'WWWW')&lt;BR /&gt;INLINE [&lt;BR /&gt;TestDate&lt;BR /&gt;1994/12/28&lt;BR /&gt;1994/12/29&lt;BR /&gt;1994/12/30&lt;BR /&gt;1994/12/31&lt;BR /&gt;1995/01/01&lt;BR /&gt;1995/01/02&lt;BR /&gt;1995/01/03&lt;BR /&gt;1995/01/04&lt;BR /&gt;1995/01/05&lt;BR /&gt;1995/01/06&lt;BR /&gt;1995/01/07&lt;BR /&gt;1995/01/08&lt;BR /&gt;1995/01/09&lt;BR /&gt;1995/01/10&lt;BR /&gt;1995/01/11&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;Do you mind testing what your output is with the same values for&amp;nbsp;FirstWeekDay, BrokenWeeks and ReferenceDay?&lt;/P&gt;&lt;P&gt;I'm a bit baffled&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":upside_down_face:"&gt;🙃&lt;/span&gt;...&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 08:43:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1719542#M54681</guid>
      <dc:creator>Mauritz_SA</dc:creator>
      <dc:date>2020-06-17T08:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1719550#M54687</link>
      <description>&lt;P&gt;Change the variable value like:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SET FirstWeekDay=&lt;STRONG&gt;0&lt;/STRONG&gt;;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and reload the app. Then check the output at the UI.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 09:07:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1719550#M54687</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2020-06-17T09:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1719652#M54697</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason why I said I don't think the FirstWeekDay is the problem is because both weeks start on the same day. But I changed it anyways:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Load_Script.png" style="width: 836px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35722i828505E352EF2D23/image-size/large?v=v2&amp;amp;px=999" role="button" title="Load_Script.png" alt="Load_Script.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Below is the resulting output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dates3.png" style="width: 641px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35723iA73BA10428DFB174/image-size/large?v=v2&amp;amp;px=999" role="button" title="Dates3.png" alt="Dates3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As you can see there is still exactly one one week difference.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jun 2020 13:06:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1719652#M54697</guid>
      <dc:creator>Mauritz_SA</dc:creator>
      <dc:date>2020-06-17T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1720191#M54771</link>
      <description>&lt;P&gt;Perhaps&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148"&gt;@rwunderlich&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/46628"&gt;@sunny_talwar&lt;/a&gt; have an idea?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 00:20:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1720191#M54771</guid>
      <dc:creator>Mauritz_SA</dc:creator>
      <dc:date>2020-06-19T00:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1720253#M54776</link>
      <description>&lt;P&gt;Since you are dealing with all sorts of weeks (even the last ones of a year), you should also consider the broken week variable. Try like:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SET FirstWeekDay=0;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;SET BrokenWeeks=0;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tresesco_0-1592552137867.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35846i2041504A996DA262/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tresesco_0-1592552137867.png" alt="tresesco_0-1592552137867.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2020 07:36:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1720253#M54776</guid>
      <dc:creator>tresB</dc:creator>
      <dc:date>2020-06-19T07:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721287#M54862</link>
      <description>&lt;P&gt;Also consider that ISO 8601 requires reference day set to 4.&lt;/P&gt;&lt;P&gt;Note that Week() by default uses ISO 8601, while weekname looks at the script variables.&lt;/P&gt;&lt;P&gt;But you can use the optional Week() function parameter to tweak accordingly:&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;&lt;A href="https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/DateAndTimeFunctions/week.htm" target="_blank" rel="noopener"&gt;https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/DateAndTimeFunctions/week.htm&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 13:33:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721287#M54862</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2020-06-23T13:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721466#M54882</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22949"&gt;@tresB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you once again for the replies. My requirement is to match the app's Year-Week field with Outlook's default settings (at least in our region). This is what Outlook is set to:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Outlook.png" style="width: 632px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36126iDF9E443E9EC0BE76/image-size/large?v=v2&amp;amp;px=999" role="button" title="Outlook.png" alt="Outlook.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have set the script variables to the following:&lt;/P&gt;&lt;P&gt;SET FirstWeekDay=6; -&amp;gt; I want the first&amp;nbsp; day of the week to be Sunday&lt;BR /&gt;SET BrokenWeeks= 0; -&amp;gt; It seems like Outlook doesn't use broken weeks&lt;BR /&gt;SET ReferenceDay=1; -&amp;gt;&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;, thanks for pointing this out. When I looked at Dec 1997 and Jan 1998 I realised that setting this to four is the equivalent of the First 4-day week option in the Outlook calendar:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Four day week in Outlook.png" style="width: 228px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36127iFBEB765A1E4A0232/image-size/large?v=v2&amp;amp;px=999" role="button" title="Four day week in Outlook.png" alt="Four day week in Outlook.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By using the variables above, I am able to get a perfect match to Outlook using the Week function. However, the weekname function remains off by 1 week for the most part and 2 weeks when looking at 1994/12/28 - 1994/12/31.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Qlik_vs_Outlook.png" style="width: 825px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36129i4FB2D1C2A781F976/image-size/large?v=v2&amp;amp;px=999" role="button" title="Qlik_vs_Outlook.png" alt="Qlik_vs_Outlook.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The reason why I am asking all of these questions is because I have added a Year-Week dimension to our autocalendar script and I used weekname() for the function as it returns a dual which is nice for calculations where the year is relevant too. The question I have now is whether I should rather build a function using Dual(Year(TestDate)&amp;amp;'/'&amp;amp;Num(Week(TestDate),'00'),WeekStart(TestDate)) or whether there is something I am missing with the built in weekname function which is returning the wrong week. I feel like the custom function will work better, but I also don't want to use a workaround if there is a flaw in my understanding or configuration.&lt;/P&gt;&lt;P&gt;Here is the script I used for the table above (and I also included the custom function I mentioned above):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;SET FirstWeekDay=6;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SET BrokenWeeks= 0;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SET ReferenceDay=1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;TestDates:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;LOAD&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Usecase,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;TestDate,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Week(TestDate),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Weekname(TestDate),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Dual(Year(TestDate)&amp;amp;'/'&amp;amp;Num(Week(TestDate),'00'),WeekStart(TestDate)),&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Date(TestDate,'WWWW')&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;INLINE [&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Usecase,TestDate&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/28&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/29&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/30&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1994/12/31&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/01&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/02&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/03&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/04&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/05&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/06&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/07&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/08&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/09&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/10&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;1,1995/01/11&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/28&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/29&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/30&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1995/12/31&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/01&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/02&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/03&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/04&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/05&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/06&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/07&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/08&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/09&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/10&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;2,1996/01/11&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;];&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Thanks again for all the helpful input, I really appreciate it.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jun 2020 21:19:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721466#M54882</guid>
      <dc:creator>Mauritz_SA</dc:creator>
      <dc:date>2020-06-23T21:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721839#M54919</link>
      <description>&lt;P&gt;Which Qliksense version are you running? Have you already tried with the latest June 2020 SR1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="swuehl_0-1593016634929.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/36197i92E468F2DB213270/image-size/medium?v=v2&amp;amp;px=400" role="button" title="swuehl_0-1593016634929.png" alt="swuehl_0-1593016634929.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 16:37:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721839#M54919</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2020-06-24T16:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Week and weekname functions giving different results</title>
      <link>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721880#M54923</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/22245"&gt;@swuehl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently on June 2019 (as our server hasn't been updated yet). I will do an install of June 2020 tomorrow and see if it fixes the issue. Thanks for the help.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mauritz&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jun 2020 19:39:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Week-and-weekname-functions-giving-different-results/m-p/1721880#M54923</guid>
      <dc:creator>Mauritz_SA</dc:creator>
      <dc:date>2020-06-24T19:39:41Z</dc:date>
    </item>
  </channel>
</rss>

