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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

how to generate dates backwards using addmonths function ?

The scenario is like this,

if i select today's date i.e 15-06-2015 the i need to generate 12 number of dates in backward manner for each month, for example

for date 15-06-2015, it should generate-

15-05-2015

15-04-2015

15-03-2015

15-02-2015

15-01-2015

15-12-2014

15-11-2014

15-10-2014

15-09-2014

.

.

.

15-06-2014




Thanks.

32 Replies
Not applicable
Author

no , actually i want to decrease the 'MM' value , not the 'DD' value.

thanks.

sunny_talwar

Give this a try and use Max(YourDateField) instead of Today()

=Date(AddMonths(Today(), -1), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -2), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -3), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -4), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -5), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -6), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -7), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -8), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -9), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -10), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -11), 'DD/MM/YYYY') & Chr(13) &

  Date(AddMonths(Today(), -12), 'DD/MM/YYYY')

giakoum
Partner - Master II
Partner - Master II

ifit is only one selected date

otherwise it will not work

sunny_talwar

Not true, Max(Date) will work in multiple selections as well. (Note: I am not using Only(Date))

Not applicable
Author

Hi ,

isn't there a more efficient way to do it ?

thanks

giakoum
Partner - Master II
Partner - Master II

yes but if I as a user select 2 dates, I expect to it work for both, not only the max

I all comes down to what Ajinkya is trying to achieve here...

sunny_talwar

Yup, that is absolutely true

It ultimately comes down to what ajinkya333 wants to achieve.

Not applicable
Author

actually user will select only one date at a time.

Not applicable
Author

can we use iterno function somehow ?

Anonymous
Not applicable
Author

Hi,

I do two solutions.

The first with object calendar and the second with listbox.

I hope this can help you.

Regards

/Giuseppe