0

# How to use substr function with dynamic value ?

Apr 26, 2017 at 06:56 PM

61

Former Member

"Default = 1 if VGW03 is up to 3 decimal places. Else multiply by factor used in VGW03"

We have fields like this..

VGW03

0.00012300000

0.0001230

0.001346

0.0006

"Default = 1 if VGW03 is up to 3 decimal places. Else multiply by factor used in VGW03" is one change in my job.

VGW03 is a fields with decimal values(0.006400000,14.000650000 like etc..) and I have to pass the value as per the above logic.

As per my understanding we can use..

ifthenelse(table1.VGWO3='0.000',table1.VGWO3, Substr(lenght(rtrim(table1.VGWO3,'0')-3,'1','12'))

we have to use like this but some where it went wrong !! facing syntax error and also if more than 3 decimal value we have to multiply by factor as dynamically as per the above condition. how to made the changes for this please comment If any one have any idea !!

Raghu Govindarajan Apr 26, 2017 at 07:14 PM
0

It looks like you just copied and pasted a line out of a specification without real context. I am not sure what that statement has to do with substr or dynamic values at all.

What is VGW03? From your explanation, it is numeric data.... if you are trying to use substr to parse the decimals - why? There are countless ways you can derive this mathematically. You could also use MOD & DIV arithmetic operators to help.

Show 1 Share
Former Member

Hello Raghu,

"Default = 1 if VGW03 is up to 3 decimal places. Else multiply by factor used in VGW03" is one change in my job.

VGW03 is a fields with decimal values(0.006400000,14.000650000 like etc..) and I have to pass the value as per the above logic.

As per my understanding we can use..

ifthenelse(table1.VGWO3='0.000',table1.VGWO3, Substr(lenght(rtrim(table1.VGWO3,'0')-3,'1','12'))

we have to use like this but some where it went wrong !! facing syntax error and also if more than 3 decimal value we have to multiply by factor as dynamically as per the above condition. how to made the changes for this please comment If any one have any idea !!

Please confirm If I am right Page or not !!!

Thanks