Page 1 of 1

Formatting valus

Posted: Fri May 01, 2009 4:03 am
by svga
Hi,

I need to format my input value based on the length of the target column.
So the length in the 2nd argument of Fmt function should be a variable.

I assign below value to one of the stage variable.

StageVar1 = '"':StageVar:"'0'R" : '"'

The StageVar is holding the varaible length.

Finally, Im using Fmt function as Fmt("45", StageVar1). But the leading zeros is not getting inserted to the value based on the value of StageVar.

Please help me to acheive this requirment.

Posted: Fri May 01, 2009 6:14 am
by Sainath.Srinivasan
Is your target a number ?

Posted: Fri May 01, 2009 6:48 am
by svga
Yes

Posted: Fri May 01, 2009 6:51 am
by chulett
The value or the target field's data type? Your target field will need to be a string in order to retain the leading zeroes you are attempting to put there.

Posted: Mon May 04, 2009 1:59 am
by svga
Hi,

The target datatype is varchar. Am I using the fmt function correctly?

Posted: Mon May 04, 2009 6:38 am
by chulett
How can your target column have a variable length? You 'zero pad' and right-align something to a fixed length. Either hard-code the length in the FMT function or explain why you can't.