Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

sum of month between from and to date

hi guys,

Is there any posibility can we some the  no. of month between from and to date.

After selecting from and to date no. of month should be calculated.

e.g

if i select from date - 01/01/2011 and to date-01/07/2013 (format of date is dd/mm/yyyy) in slider/calender.

so no. of is 31 month is the answer.

Is there any solution relate to that so please help me out to this resolve.

1 Solution

Accepted Solutions
koushik_btech20
Creator
Creator

Use these part as script....

AdhocDate:
LOAD * Inline [
FromDate,ToDate
01/04/2013,05/07/2013
10/06/2013,06/08/2013
01/01/2011,01/07/2013
];


Date:
Load
    Date(FromDate,'DD/MM/YYYY') as %FromDate,
    Date(ToDate,'DD/MM/YYYY') as %ToDate
Resident AdhocDate;

DROP Tables AdhocDate;

In UI part:

Take Two List box %FromDate and %ToDate

and use a expression in a text object which is...

='Difference : '&((year(%ToDate) * 12) + month(%ToDate) - (((year(%FromDate) * 12) + month(%FromDate))) + 1)

check these....

View solution in original post

6 Replies
tresesco
MVP
MVP

try this:

Ceil((Date1-Date2)/30)

Anonymous
Not applicable
Author

Hi tres,

Its a dynamic date selection in slider/calender based on that the expression should sum the no. of month between from and to date.

tresesco
MVP
MVP

so, store the two dates(from and to) in two variables and then use the functions as above. right?

Ceil((Variable1-Variable2)/30)

koushik_btech20
Creator
Creator

Use these part as script....

AdhocDate:
LOAD * Inline [
FromDate,ToDate
01/04/2013,05/07/2013
10/06/2013,06/08/2013
01/01/2011,01/07/2013
];


Date:
Load
    Date(FromDate,'DD/MM/YYYY') as %FromDate,
    Date(ToDate,'DD/MM/YYYY') as %ToDate
Resident AdhocDate;

DROP Tables AdhocDate;

In UI part:

Take Two List box %FromDate and %ToDate

and use a expression in a text object which is...

='Difference : '&((year(%ToDate) * 12) + month(%ToDate) - (((year(%FromDate) * 12) + month(%FromDate))) + 1)

check these....

Anonymous
Not applicable
Author

thanks it's work

orital81
Partner - Creator III
Partner - Creator III

Try This:

Num#(Year(Date1)&Month(Date1))-Num#(Year(Date2)&Month(Date2))

See attached example