Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
JianangZhao
Contributor II
Contributor II

How to generate one temperate table by using one date

Hello guys,

i want to generate one temperate table like below, when i trans one date(2019-01-01) into the temperate table, then it will be set as the field "Date_1"(2019-01-01), for field "Date_2", it will be calculated as one date range from date(2019-01-01) to date+370(2020-01-06), i try to realize in load * inline, but i find inline table doesn't support date function, so could you help me how to achieve this function? thanks for all.

Date_1Date_2
2019-01-012019-01-01
2019-01-012019-01-02
2019-01-012019-01-03
.. 
... 
2019-01-012020-01-04
2019-01-012020-01-05
2019-01-012020-01-06
1 Solution

Accepted Solutions
StarinieriG
Partner - Specialist
Partner - Specialist

Hi, 

 

you could try to do it using "for"

Date:
LOAD * INLINE [
Date
2019-01-01
2019-02-01
];

FOR n = 0 to NoOfRows('Date')-1

LET Date = Date#(Peek('Date',$(n),'Date'),'YYYY-MM-DD');

For i = 0 to 370

TABLE:
LOAD
Date('$(Date)') AS Date_1,
Date('$(Date)'+$(i)) AS Date_2
AutoGenerate(1);

NEXT

NEXT

View solution in original post

2 Replies
StarinieriG
Partner - Specialist
Partner - Specialist

Hi, 

 

you could try to do it using "for"

Date:
LOAD * INLINE [
Date
2019-01-01
2019-02-01
];

FOR n = 0 to NoOfRows('Date')-1

LET Date = Date#(Peek('Date',$(n),'Date'),'YYYY-MM-DD');

For i = 0 to 370

TABLE:
LOAD
Date('$(Date)') AS Date_1,
Date('$(Date)'+$(i)) AS Date_2
AutoGenerate(1);

NEXT

NEXT

JianangZhao
Contributor II
Contributor II
Author

Hi StarinieriG,

Yeah, it works to me. Really appreciate for your solution.