Page 1 of 1

timestamp to integer

Posted: Thu Jul 05, 2012 1:32 pm
by marpadga18
hi
I am having a source column as timestamp and my target column is integer.

column
2011-07-29 00:00:00.000

in xfm
I am doing
in.column[1,4]:in.column[6,7]:in.column[9,10] but is is giving me 0 in the output
I did this beofre it worked long back but now it is not working.could you tell me what is the problem.Thanks all

Posted: Thu Jul 05, 2012 2:08 pm
by chulett
The substring operators do not work from start position to end position as you've coded it but rather they use start position and length.

Posted: Thu Jul 05, 2012 2:15 pm
by marpadga18
hi chutlet

Is there nay way to do chutlet....I am trying to remove "-" so that it becomes integer but could you tell me how to acheive it.
Thanks M

Posted: Thu Jul 05, 2012 2:22 pm
by chulett
I already did tell you how to achieve it - correct your syntax.

Posted: Thu Jul 05, 2012 2:45 pm
by marpadga18
Hi chutlet I tried in transformer with this syntax

in.column[1,4]:in.column[6,7]:in.column[9,10] when I validated this syntax it is valid I could not find any syntax errors if you could correct me that would be great.

Thanks M

Posted: Thu Jul 05, 2012 2:59 pm
by ankursaxena.2003
Initially you will have to convert the TimeStamp to String using TimestampToString(%timestamp%,[%"%yyyy-%mm-%dd %hh:%nn:%ss"%]) function.

After wards you can apply your substring function. But, as Chulett said your syntax is wrong. It should be as shown below:

in.column[1,4]:in.column[6,2]:in.column[9,2]

And later on if you need then you can convert this String to Decimal.

Posted: Thu Jul 05, 2012 3:04 pm
by chulett
Once more with feeling - you have (as one example) "in.column[6,7]" where you are telling it to substring from position 6 to position 7. That is not the correct syntax. You need to tell it to start in position 6 and substring out 2 characters: "in.column[6,2]"

Once they are all correct, you should be much closer to your goal.

Posted: Thu Jul 05, 2012 8:06 pm
by qt_ky
The syntax is correct; the values are incorrect. :wink:

Posted: Thu Jul 05, 2012 8:12 pm
by chulett
Therefore, the syntax is incorrect. :D

Posted: Thu Jul 05, 2012 8:18 pm
by qt_ky
Ahhhh, but... there were no syntax errors. :shock:

Posted: Thu Jul 05, 2012 11:52 pm
by vamsi.4a6
@chullet
Here source is Timestamp so can i apply substring operator directly or do i need to convert Timestamp to string and then i need to apply substring operator

As per my knowledge we can not apply substring operator directly to timestamp we need to convert timestamp to string before applying substring operator.Please correct me if i am wrong?

Posted: Fri Jul 06, 2012 2:55 am
by marpadga18
chulett wrote:Therefore, the syntax is incorrect. :D
Hi Chutlet thanks for correcting me. What you said is right.
Thanks for all

Posted: Fri Jul 06, 2012 3:04 am
by chandra.shekhar@tcs.com
No need to use substr and then concatenating your column.
This will work too 8)

Code: Select all

TimestampToString(%timestamp%,["%yyyy%mm%dd"])

Posted: Fri Jul 06, 2012 6:33 am
by chulett
True. My primary goal here was to correct the mis-use of the substring operator. As noted, they're not needed at all to accomplish the goal here, however if one is going to use them they need to be used correctly. :wink: