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: 
Not applicable

Find the difference between months

Hi, good day everyone !

I want to get the number of months between 2 months. where

The expression I am using is

Month ([Expiry Date])-$(@calendarMonth) where Month([Expiry Date]) returns result like 'Aug' and $(@calendarMonth) returns result like 'July'.

Is it I need to convert the month string to number ?

Thanks sincerely for your help 🙂

1 Solution

Accepted Solutions
Sokkorn
Master
Master

Hi,

Try function NUM(). It look like NUM(Month ([Expiry Date]))

Regards,

Sokkorn

View solution in original post

10 Replies
Sokkorn
Master
Master

Hi,

Try function NUM(). It look like NUM(Month ([Expiry Date]))

Regards,

Sokkorn

Not applicable
Author

Thanks Sokkorn Cheav, it works for the Expiry Date. How about the $(@calendarMonth) ?
I tried Num($(@calendarMonth)) but it does not return me 6 when I selected Jun.

Regards

 

Sokkorn
Master
Master

Hi,

Can you give me the expression of this variable $(@calendarMonth)?  Where you get it from? Or you can share your app.

Regards,

Sokkorn

Not applicable
Author

The expression for variable @calendarMonth is =GetFieldSelections(PeriodMonth).

It is from a list box selection. For example, when user select 'Jun', I need to pass 6 into my expression

Month ([Expiry Date])-$(@calendarMonth). Thus, the result will be 8-6 =2

Sokkorn
Master
Master

Hi,

Your variable expression =GetFieldSelections(PeriodMonth)
will return string value something like 'Jun'. So you need to convert it into number with this expression @calendarMonth = GetFieldSelections(Match(PeriodMonth, $(=chr(39) & Replace(MonthNames, ';', chr(39) & ',' & chr(39)) & chr(39))))

Test it and let me know the result.

Regards,

Sokkorn

Anonymous
Not applicable
Author

hi ,

      Sokkorn is right bt much easy way u can work is with following expression

    

         date(date#(GetFieldSelections(PeriodMonth),'MMM'),'MM')

regards,

Vaibhav

Not applicable
Author

Hi,

I have changed the expression of @calendarMonth to =GetFieldSelections(Match(PeriodMonth, $(=chr(39) & Replace(MonthNames, ';', chr(39) & ',' & chr(39)) & chr(39))

but variable $(@calendarMonth) returns nothing when the 'Jun' is selected in the listbox Calendar Month.

Regards,

Sokkorn
Master
Master

Hi,

Is it possible to upload your app here?

Regards,

Sokkorn

Anonymous
Not applicable
Author

hi

can u plz try

date(date#(GetFieldSelections(PeriodMonth),'MMM'),'MM')

n let me knw?