# New to QlikView

Discussion board where members can get started with QlikView.

Announcements

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
Honored Contributor

## Re: Find the difference between months

Hi,

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

Regards,

Sokkorn

10 Replies
Honored Contributor

## Re: Find the difference between months

Hi,

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

Regards,

Sokkorn

Not applicable

## Re: Find the difference between months

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

Honored Contributor

## Re: Find the difference between months

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

## Re: Find the difference between months

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

Honored Contributor

## Re: Find the difference between months

Hi,

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

Contributor II

## Re: Find the difference between months

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

## Re: Find the difference between months

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,

Honored Contributor

Hi,

Regards,

Sokkorn

Contributor II

## Re: Find the difference between months

hi

can u plz try

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

n let me knw?

Community Browser