Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Load dates in script

I want to create a list in the script which contains all the last 11 months, which will get updated dynamically

For example if i am running the app on 27th Sept 2017 , i should get the following list :


Oct 2016

Nov 2016

Dec 2016

Jan 2017

Feb 2017

Mar 2017

Apr 2017

May 2017

Jun 2017

Jul 2017

Aug 2017

Please help me on this.

1 Solution

Accepted Solutions
maxgro
MVP
MVP

Table:

load

Date(AddMonths(MonthStart(today()), -iterno()), 'MMM YY') as Date

AutoGenerate 1

While IterNo() <= 11;

1.png

View solution in original post

7 Replies
YoussefBelloum
Champion
Champion

Hi,

here is one of the methods to do it:

SET v_STARTDATE = '01/01/2016';

SET v_ENDDATE = '01/12/2017';

TMP_DATE:

LOAD date(date#('$(v_STARTDATE)','DD/MM/YYYY')-1 + recno() ,'DD/MM/YYYY') as Date

AUTOGENERATE (date#('$(v_ENDDATE)','DD/MM/YYYY') - date#('$(v_STARTDATE)','DD/MM/YYYY')) + 1 ;

DATE_TABLE:

LOAD

*,

Month(Date)&Year(Date) as Month_year

RESIDENT TMP_DATE

where Date < AddMonths(today(),-1) and Date > AddMonths(today(),-11);

DROP TABLE TMP_DATE;


Hope it helps

YB

Anonymous
Not applicable
Author

Hi,

Thanks for the reply . But i dont want to hardcode the end date.can we make it as today()?

maxgro
MVP
MVP

Table:

load

Date(AddMonths(MonthStart(today()), -iterno()), 'MMM YY') as Date

AutoGenerate 1

While IterNo() <= 11;

1.png

YoussefBelloum
Champion
Champion

Yes for sure you can put whatever you want in the variables.

Tell me if you want an example

Anonymous
Not applicable
Author

Thank you.This is exactly whai wanted

Anonymous
Not applicable
Author

Thank you Youssef for ur support

YoussefBelloum
Champion
Champion

you're welcome !