3 Replies Latest reply: Nov 28, 2012 8:39 AM by Stefan Wühl RSS

    Script function Weekname returns a monthname

    Søren Skovsgaard

      Hi

       

      I have data numbered 1 to 12 for months and 1 to 52 for weeks, and I am using Monthname and Weekname to convert it into Month and Weeks. However when doing so Week 40 2012 returns Oct 2012. See below script for example.

       

      InlineLoad:
      Load * inline [MonthNo, Year, Classification
      9, 2012, Month
      39, 2012, Week
      10, 2012, Month
      40, 2012, Week
      11, 2012, Month
      41, 2012, Week
      ];

       

      Convert:
      Load
      *,
      if(Classification = 'Month', monthname(MakeDate(Year,MonthNo,1)), Weekname(MakeWeekDate(Year,MonthNo,6)) ) as Period,
      if(Classification = 'Month', 'A', Weekname(MakeWeekDate(Year,MonthNo,6)) ) as Period1
      Resident InlineLoad;

       

      Drop table InlineLoad;

       

      For week 40, Period returns "Oct 2012" but if I dont convert to Months as in Period1 it correctly returns "2012/40"

       

      Can anyone explain why, or is this a bug?

       

      Regards

      Soren