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

Highlighted
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 )
t1_date
Table2 fields:
t2_appid (Primary Key)
t2_appname
Table3 fields:
t3_userid (Primary Key)
t3_username
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 
globalMap.get("toDate")

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

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’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

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch