Want to go 1 month back of the deliverd date: TalendDate.addDate

One Star

Want to go 1 month back of the deliverd date: TalendDate.addDate

Hi All,
I get from an excel file a string deliverd as date. This string is yyyyMMddhhmmss (Sample 20161012213300 = 12 Oct 2016 21:33:00).
I am able to parse this to date by using TalendDate.parseDate("yyyyMMddhhmmss", row1.Report_Date)
But now I want to move one month back so the deliverd date is still 20161012213300 Converted to 12 Oct 2016 and Then I want to add instead of Oct it should be Sep
I have tried it with addDate, but I get an error:
java.lang.RuntimeException: java.text.ParseException: Unparseable date: "20160930120000"
    at routines.TalendDate.parseDate(TalendDate.java:857)
    at routines.TalendDate.parseDate(TalendDate.java:801)
    at mlm.tutorexcel_0_1.TutorExcel.tFileExcelWorkbookOpen_1Process(TutorExcel.java:5167)
Thanks for the feedBack
Community Manager

Re: Want to go 1 month back of the deliverd date: TalendDate.addDate

Hi
Try this code on tJavaRow:
output_row.DateColumn=TalendDate.addDate(TalendDate.parseDate("yyyyMMddHHmmss", input_row.stringDateColumn),"-1","MM");
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Want to go 1 month back of the deliverd date: TalendDate.addDate

Thanks for your feedback,  this works.

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 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog