Page 1 of 1

Data Issue

Posted: Wed Mar 18, 2009 9:00 am
by samsuf2002
I have a column with apha, alphanumeric and numeric values, I want to pass only numeric values and want to make apha & aplhanumeric values empty.

I tried using

Code: Select all

if len(convert("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz","",col)) = 0 then "" else col
but its not working for alphanumeric values.

Then I tried

Code: Select all

If index("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz",col,1) > 0 then "" else col
this one is making numeric values empty.


Can any help me here and let me know if I am doin anything wrong in the above code.

Thanks in advance.

Posted: Wed Mar 18, 2009 9:12 am
by bart12872
you have the Num function. It returns 1 if it's a number.

Posted: Wed Mar 18, 2009 10:43 am
by jdmiceli
Well, this is kind of hokey, but should work (I'm pulling this off the top of my head and have not tested it - so make sure you do that):

Create a routine something like this:

Code: Select all

Function RemoveLetters(Arg1)

Text = Arg1
Ans = ""

LC = LEN(Text)

For i=1 to LC
   Letter = Text[i,1]
   Tst = Num(Letter)
   if Tst = 0
   then
      Ans := Letter
   end
Next i

RETURN (Ans)
This isn't very elegant and I'm sure someone with more experience than me with coding could do it better, but I think it will work.

Good luck!

Posted: Wed Mar 18, 2009 10:54 am
by samsuf2002
I used Num() and it gave me the result I want.

thanks bart12872 and jdmiceli.