Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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.

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Try with this, column New 1a that I created in the script.

You can also think if you want to can select only one value in Datafield listbox with a trigger.

I hope this can help you.

View solution in original post

32 Replies
giakoum
Partner - Master II
Partner - Master II

generate where? in your reload script? Day(Yourdate) & Month(Yourdate)-iter() & Year(yourdate) should do it with a while statement. Just format it correctly

Not applicable
Author

hello,

when i select a particular date in a calendar table then i need to display that 12 dates in a textbox.

thanks

giakoum
Partner - Master II
Partner - Master II

my suggestion is that you generate those dates in your reload script as I explained above and then use concat to display them in the text object

What is the purpose of that actually?

sunny_talwar

Do you want to display something like this?

Capture.PNG

Try this (I used Today(), but you can use Max(DateField))

=Date(Today() -1) & Chr(13) &

  Date(Today() -2) & Chr(13) &

  Date(Today() -3) & Chr(13) &

  Date(Today() -4) & Chr(13) &

  Date(Today() -5) & Chr(13) &

  Date(Today() -6) & Chr(13) &

  Date(Today() -7) & Chr(13) &

  Date(Today() -8) & Chr(13) &

  Date(Today() -9) & Chr(13) &

  Date(Today() -10) & Chr(13) &

  Date(Today() -11) & Chr(13) &

  Date(Today() -12)

giakoum
Partner - Master II
Partner - Master II

Sunindia what you suggest works only for today.

Ajinkya wants : when i select a particular date in a calendar table then i need to display that 12 dates in a textbox.

giakoum
Partner - Master II
Partner - Master II

and it is not the previous 12 day, it is the previous 12 months with that date

sunny_talwar

My bad, just realized you have Date as DD/MM/YYYY and I think you needed last 12 months like this:

Capture.PNG

Expression:

=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')

burli1895
Contributor III
Contributor III

Look at this: Change Date by Button

sunny_talwar

We just need to replace Today() with Max(DateField) to make it work for the selection, isn't that true? and Yes I realized that he wanted to go back 12 months instead of 12 dates, so I changed my expression in the below post.