Four Stars

How to achive from one Date to multiple dates

sourcesourcetargettarget

By using this source file how to get multiple dates in order

 

  • Data Integration
  • ESB
6 REPLIES
Seven Stars TRF
Seven Stars

Re: How to achive from one Date to multiple dates

Using TalendDate routines (https://help.talend.com/display/TalendOpenStudioforBigDataUserGuide520EN/10.5+TalendDate+Routines) compute the difference between start and end date, then tLoop from 1 to nb_days, add i to start date giving current date. You got what you need for your job.

TRF
Four Stars

Re: How to achive from one Date to multiple dates

Can you please help me.I tried with tjava and tloop but not able to do

Six Stars

Re: How to achive from one Date to multiple dates

This is actually a bit tricky.

 

  

I did some rough work and came up with this solution. Hope it gives you some idea.

 

You have to first calculate the difference between the start date and end date and store it in a context value.

Then for each row, you have to use the tLoop component to generate the missing dates.

 

The layout of the job,

dataFlow.PNG

tMap12 Config,

tMap12.PNG

 

tJava Code,

 

tjava1.PNG

 

tLoop Config,

tLoop.PNG

tFixedFlow Component Config,

tfixedFlow.PNG

 

 

 

tMap13 config,

tMap13.PNG

Here we have two contexts created. One is the context Loop of integer datatype for storing the max loop number.

Other one is the context startDate of datatype date for storing the starting date.

Remember to check the append option if your output is a file.

 

There might be a better way to do this. Hopefully this template gets you started on what you want.

 

 

 

 

Four Stars

Re: How to achive from one Date to multiple dates

thank u very much i will try and let u know

Seven Stars TRF
Seven Stars

Re: How to achive from one Date to multiple dates

Hi,

Thanks to @ArvinRapt to have detailed the solution I proposed.

I don't think it's too much tricky.

Maybe you can change tJava by tSetGlobalVar and use global variables instead of context variables, but it's a detail.

Also I think you can move the operation made in the tMap into the tFixedFlowInput component to comple the startDate field.

 

Regards,


TRF
Six Stars

Re: How to achive from one Date to multiple dates

@TRF Agreed. Those two suggestions make the job easier on the eyes.