Page 1 of 1

What is substr equivalent for transformer

Posted: Fri Nov 04, 2011 7:17 am
by Developer_AK
Hi All,


I got a situation where I need to perform sub string operation. Can any one tell me how to do a substr action in Transformer ?


Sample data:
2004041 xxx yyy34


This is a fixed length data. the desired out put is
Output:
year month week name code rowNo
2004 04 1 xxx yyy 34


So needs to perform a sub string operation.

Thanks

Posted: Fri Nov 04, 2011 7:27 am
by suse_dk
You need to do is define the start point and length in bracket after the source column and map it to your target column, for instance...

YourColumnName[1,4] mapped to year
YourColumnName[5,2] mapped to ...
YourColumnName[7,1]
YourColumnName[9,3]
YourColumnName[13,3]
YourColumnName[16,2]

Posted: Fri Nov 04, 2011 7:28 am
by chulett
The square brackets [] are the substring operator. So "YourSample[1,4]" will get you "2004", "YourSample[5,2]" will get you "04", etc etc.

:lol: Too slow.

Posted: Fri Nov 04, 2011 3:24 pm
by ray.wurlod
A word of warning. 2004041 might mean the 41st day of 2004. In that case you need to use StringToDate() with a mask of "%yyyy%ddd" to yield a date, then date component functions to extract the relevant pieces of date (year, month and day).