[resolved] date math - how can Talend add or subtract X number of days?

Nine Stars

[resolved] date math - how can Talend add or subtract X number of days?

How can you add or subtract X number of days with Talend?
For example my date is '2013-04-22' how can Talend subtract 5 days and return '2013-04-17'?

Accepted Solutions
One Star

Re: [resolved] date math - how can Talend add or subtract X number of days?

You can use following expression to move date 5 days back

TalendDate.addDate("2013-04-22","yyyy-MM-dd",-5,"dd")

All Replies
One Star

Re: [resolved] date math - how can Talend add or subtract X number of days?

You can use following expression to move date 5 days back

TalendDate.addDate("2013-04-22","yyyy-MM-dd",-5,"dd")
Nine Stars

Re: [resolved] date math - how can Talend add or subtract X number of days?

Thanks oz69! Works great.

Re: [resolved] date math - how can Talend add or subtract X number of days?

I have a excel sheet where Column B is a date and Column E is a number. I want number of days in Column E to be reduced from Column B and stored in Column F
Input be like,
Column B|Column E|Column F
2014-05-13|4|
2014-06-12|2|
Output be like,
Column B|Column E|Column F
2014-05-13|4|2014-05-09
2014-06-12|2|2014-06-10
Anybody up for help??
One Star

Re: [resolved] date math - how can Talend add or subtract X number of days?

hi guru,
use tmap

Expression of column F:
TalendDate.addDate(row1.columnB,"yyyy-MM-dd",-row1.columnE,"dd")

Re: [resolved] date math - how can Talend add or subtract X number of days?

Hi Jcs19,
You are subtracting date from date... I need to subtract number of days from date...
One Star

Re: [resolved] date math - how can Talend add or subtract X number of days?

Hi Jcs19,
You are subtracting date from date... I need to subtract number of days from date...

What?
I thought you wanted column F = Column B(date) - Column E(number of day)
In my example, i'm subtracting column E as number of day to column B to make column F

Re: [resolved] date math - how can Talend add or subtract X number of days?

but the datatytpe shown in expression editor is date and not integer
One Star

Re: [resolved] date math - how can Talend add or subtract X number of days?

but the datatytpe shown in expression editor is date and not integer

Oh yes, column E should be integer not date (I made this example too fast Smiley Tongue)