Fetching tomorrow date's data (addDate function) from DB

One Star

Fetching tomorrow date's data (addDate function) from DB

Dear guys ,
I have three tables with relations. table1 , table2 and table3
Table1 fields :
t1_userid       ( Foreign key of t3_userid )
t1_appid        ( Foreign key of t2_appid )
Table2 fields:
t2_appid (Primary Key)
Table3 fields:
t3_userid (Primary Key)
Now i want to fetch tomorrow date (t1_date) data's
So i designed job like this

tjava component (add_date)
String d=TalendDate.getDate("YYYY-MM-DD");
String ad=TalendDate.addDate(d,"yyyy-MM-dd",+1,"dd");
Tomorrow's date i will get from tjava component (add_date)
I want to construct a output with t1_appname , t3.username and t1_date (tomorrow's date) fields
Help me to do this
Thanks & Regards,
Vinoth Kumar K

Re: Fetching tomorrow date's data (addDate function) from DB

Hi Vinoth,
I would suggest you to make use of global map. 
Get current date - > add a day -> put the new date in global map  and then get that value where ever you need it.
Date date = TalendDate.getCurrentDate();
Date toDate = TalendDate.addDate(date, 1,"dd");
globalMap.put("toDate", toDate);
Or if you want date as string.
String date = TalendDate.getDate("yyyy-MM-dd");
String toDate = TalendDate.addDate(date, "yyyy-MM-dd", 1, "dd");
globalMap.put("toDate", toDate);

Now in the expression field for t1_date put this 

You can use date as it is if column type is Date, you can specify the date format there.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables


How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration


Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now