Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to write a variable?

Hi,

I have a variable $'(vMonthENDDATE)'= date(monthend(today(),0),'YYYYMMDD') which returns the value of 20161130(Current Month End date)

What should be the expression  if I want to create a variable to return the value of 20161031?(Previous Month end date)

6 Replies
ArnadoSandoval
Specialist II
Specialist II

Hi Badhikari,

The expression will be:

date(monthend(today(), -1),'YYYYMMDD')

Which is pretty similar to yours, the difference is the -1 instead of zero.

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
praveenkumar_s
Creator II
Creator II

use $1 instead of $...

Thanks,

Praveen Kumar S

maxgro
MVP
MVP

maybe

the previous month end of current month end date

is 1 day before current month start

=date(monthstart(today()) -1, 'YYYYMMDD')

Anonymous
Not applicable
Author

=Date(MonthStart(Today())-1,'YYYYMMDD')

Anonymous
Not applicable
Author

You can try something like this.

vPriorMonthENDDATE = Addmonths(vMonthENDDATE,-1)

Lech_Miszkiewicz
Partner Ambassador/MVP
Partner Ambassador/MVP

This will not work

For Example: 28th of February will return 28th of January which is not a month end. You would have to include MonthEnd formula again like:

vPriorMonthENDDATE = MonthEnd(Addmonths(vMonthENDDATE,-1))

I however would follow maxgro suggestion:

=date(monthstart(today()) -1, 'YYYYMMDD')



hth

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.