Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello Everyone,
In my code, whenever I pick source files I need to pick T-1 date files. So when I subtract the month starting date with -1 using the below expression it results to incorrect date value,
Expression :
context.Load_Date=String.valueOf(Integer.parseInt(TalendDate.getDate("YYYYMMDD"))-1);
Example :
Input Date = 20210101
Output Date Value received after subtracting 1 = 20210200
The format of the date is YYYYMMDD.
Can you help with a solution to fix this issue.
Thank you.
Hello @Rajesh L R ,
Please try using the below logic;
Date a=TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd");
System.out.println(TalendDate.formatDate("yyyyMMdd", a));
Please let us know if it helps. If yes, mark it resolved (Kudos also accepted).
Regards,
Vaishnavi
Hello @Rajesh L R ,
Could you please confirm if you mean "T-1" as the previous day?
Please provide us the expected output, so that we can check accordingly.
Regards,
Vaishnavi
Hi @Vaishnavi Khandelwal ,
Yes T-1 is previous day.
Expression :
context.Load_Date=String.valueOf(Integer.parseInt(TalendDate.getDate("YYYYMMDD"))-1);
Current Data :
Input Date : 20210301
Output Date : 20210300
Expected Data :
Input Date : 20210301
Output Date : 20210228
Hello @Rajesh L R ,
Please try using the below logic;
Date a=TalendDate.addDate(TalendDate.getCurrentDate(),-1,"dd");
System.out.println(TalendDate.formatDate("yyyyMMdd", a));
Please let us know if it helps. If yes, mark it resolved (Kudos also accepted).
Regards,
Vaishnavi
It worked, thank you @Vaishnavi Khandelwal