Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
agni_gold
Specialist III
Specialist III

Generate Months between two Months

Hi All ,

I am creating a calender , I want to create Quarter months as per date selection.

Suppose i select 01-Jan-2014,

Then Quarter will be Jan,Feb,Mar so i want to generate a Quarter Months field which will sort based on my date selection.

My Script is

Let varMinDate = Num(MakeDate(2014,1,1));

Let varMaxDate = Num(YearEnd(MakeDate(2014,1,1)));

Temp_Date:

LOAD date($(varMinDate)+IterNo()-1) AS Temp_Date AUTOGENERATE (1) WHILE $(varMinDate)+IterNo()-1<= $(varMaxDate);

Calender:

LOAD Date(Temp_Date,'DDMMMYYYY')                                           AS Date,

     Date(Temp_Date,'DDMMMYYYY')                                           AS [Order Date],

  Year(Temp_Date)                                                       AS Year,

  Month(YearStart(Temp_Date))                                           AS [Year Start Month],

  Month(YearEnd(Temp_Date))                                             AS [Year End Month],

  Month(YearEnd(Temp_Date)-YearStart(Temp_Date))                        AS [Year Months],

  Month(Temp_Date)                                                      AS Month,

  Dual(Date((Temp_Date),'MMMM'),Num(Month(Temp_Date)))                  AS Months,

  Floor(Monthstart(Temp_Date))                                          AS Monthstart,

  Week(Temp_Date)                                                       AS [Week],

     Weekday(Temp_Date)                                                    AS [Days Name],

  Day(Temp_Date)                                                        AS Day,

  'Q ' & Num(Ceil(Month(Temp_Date)/3),'(ROM)0')                         AS Quarter,

  Month(QuarterStart(Temp_Date))                                        AS [Quarter Start Month],

  Month(QuarterEnd(Temp_Date))                                          AS [Quarter End Month],

  Month(QuarterEnd(Temp_Date)-QuarterStart(Temp_Date))                  AS [Quarter Months],

  Monthname(Temp_Date)                                                  AS [Month Name],

  Num(Monthname(Temp_Date))                                             AS [Rooling Month],

  (Num(Floor(Monthend(Temp_Date)))-Num(Floor(Monthstart(Temp_Date)))+1) AS [Number of Days in Month],

  If(Num(Weekday(Temp_Date))<5,1,0)                                     AS [Working Days]

RESIDENT Temp_Date;

DROP TABLE Temp_Date;

10 Replies
Anonymous
Not applicable

Hi Agnivesh,

all the given solutions are for the load script ,if these is not you are looking for please elaborate on your query?

Regards

Neetha