Page 1 of 1

Changing a character field to numeric

Posted: Sat Sep 04, 2010 4:21 pm
by brentbond
I am doing a custom report in CONTRIBUTIONS. Because of a site specific reason, I am using FAMILY PHONE 3 to contain price information (ex 100.00). In my CONTRIBUTIONS custom report I would like to subtract CONTRIBUTIONS AMOUNT from FAMILY PHONE 3. I cant do this because FAMILY PHONE 3 is a character field. Is there a way to convert this to a numeric field just for my subtraction process?

Re: Changing a character field to numeric

Posted: Sun Sep 05, 2010 7:20 am
by Zorak
You can use CAST() to change a character to a number. Your expression would look something like this:

Code: Select all

CAST(phone3 AS N(8,2))-amount
This will subtract the contribution amount from whatever number you have in family phone 3. Luckily, if some value in phone 3 is not able to be cast to a number, it will simply be zero rather than blowing up your report.