Changing a character field to numeric

Moderators: Moderators, Tech Support

Post Reply
brentbond
Posts: 49
Joined: Sat Sep 04, 2010 4:12 pm

Changing a character field to numeric

Post 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?

Zorak
Tech Support
Tech Support
Posts: 3012
Joined: Thu May 13, 2004 9:59 am
Location: PowerChurch Software
Contact:

Re: Changing a character field to numeric

Post 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.

Post Reply