Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Months Between 2 Dates

Hello!

I have the following table:

Table.png

(where START_DT and END_DT have the format: DD/MM/YYYY)

What I need is to find which months are between my 2 dates (START_DT and END_DT).

For example, in the first row I have: START_DT = 19/11/2012 and END_DT = 17/01/2013

And the result should be:

Months: 11, 12, 01

That would be the months between those 2 dates.

How can I get those values for each row?

Thank you!!!

1 Solution

Accepted Solutions
Anonymous
Not applicable

Generating Missing Data In QlikView

In the Script:

OriginalTable:

Load

*

From DataSource;

//Function to calculate Months Difference in script

SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + 1);

MonthTable:

Load

  ACCT_ID

  Month( AddMonths(START_DT ,IterNo() - 1)) as Months

Resident OriginalTable

While IterNo() <= ($(MonthDiff(START_DT, END_DT))) ;

View solution in original post

1 Reply
Anonymous
Not applicable

Generating Missing Data In QlikView

In the Script:

OriginalTable:

Load

*

From DataSource;

//Function to calculate Months Difference in script

SET MonthDiff = Num(((year($2) * 12) + month($2)) - (((year($1) * 12) + month($1))) + 1);

MonthTable:

Load

  ACCT_ID

  Month( AddMonths(START_DT ,IterNo() - 1)) as Months

Resident OriginalTable

While IterNo() <= ($(MonthDiff(START_DT, END_DT))) ;