Five Stars

Filter a Date field: from today to 30 days before

Dear all,

i have to send a report .csv everyday considering the current date and the 30 days before the current date. How can i do that?

i have obviously a date field in that format "yyyy-MM-dd" and i need to filter that field every day.

 

to make an example i have to send the report tomorrow (2018-05-19) and in the report there will be data from (2018-05-19 - 30 days) and 2018-05-19.

 

thanks in advance   

1 ACCEPTED SOLUTION

Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: Filter a Date field: from today to 30 days before

Use a tFilterRow or tMap or if your data come from a database, build a where clause based on the global variable.
You may be inspired by this link about compareDate
http://whateverybodywantsis.blogspot.fr/2017/02/talend-compare-date-function-examples.html?m=1

TRF
3 REPLIES
Forteen Stars TRF
Forteen Stars

Re: Filter a Date field: from today to 30 days before

You may set a global variable with the current date - 30 days using tSetGlobalVar: TalendDate.addDate(TalendDate.getCurrentDate(), -30, "MM")
Then use the variable to filter your input rows using the TalendDate.compareDate routine.
If your input is a database, I suggest you to build a where close using the result of TalendDate.addDate to select only the desired rows.

TRF
Five Stars

Re: Filter a Date field: from today to 30 days before

thanks for the answer,

but, where i have to put the "variaible to filter your input rows"? 

and specifically how Talend.Date.compareDate works?

 

 

Forteen Stars TRF
Forteen Stars

Re: Filter a Date field: from today to 30 days before

Use a tFilterRow or tMap or if your data come from a database, build a where clause based on the global variable.
You may be inspired by this link about compareDate
http://whateverybodywantsis.blogspot.fr/2017/02/talend-compare-date-function-examples.html?m=1

TRF