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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Varchar to numeric data type 1

Status
Not open for further replies.

mattbrenn

Programmer
Jun 4, 2003
11
GB
Crystal 10 accessing a SQL2K db.

Hi
I have a quantity field that i would like to perform a sum on, but the data type of the field set in the db is varchar. I'd like to change it to a numeric data type, but am not sure of the best way to do so. Any ideas?

TIA
Matt
 
The following checks for numeric data. Nulls and non-numerics are set to 0

Code:
//@fieldn
if isnull({table.field}) or {table.field} = "" then
  0
else if isnumeric({table.field}) then tonumber({table.field})
else 
  0

You can now perform summary totals against @field

-lw



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top