Search code examples
javavariablestalendroutines

TALEND set a context variable depending from TalendDate


I want to set a context variable depending from a TalendDate routine in the "value as Table" tab which would allow me to select the day of yesterday : TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd"))

It does not work, I do not have any returns when I include in the selection as date('"+context.date+"').

Could you please tell me what I am missing ? I would be very grateful if you could help me with that.


Solution

  • You should create a global variable, then in a tJava assign a value to it.

    Or according to your current situation, in tJava paste the following:

    context.date = TalendDate.formatDate("yyyy-MM-dd", TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd"));

    Then you can use your variable. It won't be a java Date type, but a string.