Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check a database field whether its numeric?

Status
Not open for further replies.

tttggg

Technical User
Joined
May 24, 2007
Messages
61
Location
CA
Can anyone tell ne how to check whether a field is numeric or not.
Basically I need to check a field whether its numeric or not and if its numeric then I have to convert it into number. I’m little confused how to check a database field whether its numeric?
I’m using CR 8.5 and DB2.
 
if isnumeric({table.field}) then
tonumber({table.field})

-LB
 
LB just forgot the NOT part of the code:

In not isnumberic({YourField}) then tonumber({yourfield})

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
No, actually, I didn't. If it is not numeric, it cannot be converted to a number.

-LB
 
lbass,

I usually follow your logic. Can you explain why you do it that way?

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Let's say the string could contain the following:

1234
abc
def
4567

isnumeric would return true for: 1234 and 4567 and these are the only fields that can be converted to a number.

-LB
 
I have never used isnumeric. First glance I assumed it was asking if the number was a number. Now that I have looked it up, it is asking if the "string" can be converted to a number. Got it.... thanks

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
LB,

I am properly chastised for questioning "the master". I should have known better. Obviously I had my head around some other issue when I posted!

Lbass did not get all those stars and tipmaster of the week awards by accident!

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"What version of URGENT!!! are you using?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top