checking to see if a number is a decimal

# Thread: checking to see if a number is a decimal

1. Member
Join Date
Dec 1969
Posts
70

## checking to see if a number is a decimal

From SQL Server, a number is pulled that could be a decimal or an integer. I need to check if it is a decimal and then split the decimal using deci = split((deci/60), ".") and get the actual data deci(0) and deci(1). If it is NOT a decimal, than I need to just print it out followed by a ":00". My problem is - I cannot figure out how to check if the number is a decimal, because if I just split it out and check to see if the deci(1) is not null, then I get subscript out of range errors. So, I need to check to see if it is a decimal or not FIRST before I split it. Would I use the MOD function to do this? If so, how?<BR>THank you for any help!

2. Senior Member
Join Date
Dec 1969
Posts
1,274

## RE: checking to see if a number is a decimal

I&#039;m sure there&#039;s a better way to do this, but I&#039;m feeling rather uninspired today, so...<BR><BR>Can&#039;t you just instr() the number (maybe cstr() it first) and look for a decimal? Then formatnumber() it back?<BR><BR>Just a thought.

3. Member
Join Date
Dec 1969
Posts
70

## RE: checking to see if a number is a decimal

thank you!

4. Senior Member
Join Date
Dec 1969
Posts
896

## RE: checking to see if a number is a decimal

or just use mod :) <BR><BR>if x = 5<BR>if x mod floor(x) = 1 then<BR>&#039;it&#039;s real<BR>else<BR>&#039;it&#039;s decimal<BR>endif

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•