Adding columns in transformer (Numeric)

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Adding columns in transformer (Numeric)

Post by sam334 »

Here is another interesting one.

I have 4 columns.
column1,column2,column3,column4.
0:00:00,0:00:00,0:25:13,0:10:12

I want to add these all columns in transformer,or aggregator,

column1,column2,column3,column4,Totaltime
0:00:00,0:00:00,0:25:13,0:10:12,0:35:25

Any lead..

Thanks for your help.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What are your data types for the 5 columns?
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

All are VARCHAR..
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I would imagine it's just an IConv to get them into internal "time" format, then do the addition and then OConv the result back out again.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I order to add those values, you need to convert the strings to a time, then perform the math, then convert the result back to a string.

StringToTime() will do the former, and TimeToString() will do the latter.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

<cough> Server job </cough>

Or is that a transform I'm not remembering?
-craig

"You can never have too many knives" -- Logan Nine Fingers
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Okay. understood the converting string to time.but to do the math, will concatenate work? i dont think so. any elaboration on the Calculation..
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No, you would simply add the internal time values together.
-craig

"You can never have too many knives" -- Logan Nine Fingers
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Need more info... Are those times of day or elapsed times?

If elapsed times, then the first column (hours) may go over 23 hours. 4321:59:59 could be a valid elapsed time.

Likewise, if your total is over 23:59:59 then what is your rule on how to output the result?
Choose a job you love, and you will never have to work a day in your life. - Confucius
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hey, one step at a time Eric. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

<cough> Server </cough>

Ahh, in a server job you would do an

Code: Select all

ICONV(In.column1,'MTS')
and the result is an integer number of seconds since midnight. You can add those together and use the

Code: Select all

OCONV(svSumOfSeconds,'MTS')
to get a string output. This will not go over 24 hours, so if your sum can go over that limit you would need to add a bit more logic.
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Ok ArndW. My renewal is in process,so cant see the whole explanation. From the part of it, seems like,

Use, ICONV(IN.Column1.'MTS' code for each column and then add those columns as stage variable and linkup to a total time column.

But when using ICONV(IN. ---- it is asking for concatinate,substring,matches,And or OR rather input column)
meaning, straight ICONV(IN.DSLink.Column1,'MTS') not accepting.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not sure what you mean by it is "asking for" anything, there's nothing more to the syntax than what Arnd posted. Can you be more specific? Examples from the documentation are here. Is your "Column1" a string?
-craig

"You can never have too many knives" -- Logan Nine Fingers
sam334
Premium Member
Premium Member
Posts: 145
Joined: Mon Aug 26, 2013 7:42 pm

Post by sam334 »

Sorry for the work "asking", it is not appropriate for sure. :)

Yes, my input data is string.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then you should be fine... just make sure your input column name is correctly specified. The example you posted has too many "dots" in it:

Code: Select all

ICONV(IN.DSLink.Column1,'MTS')
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply