cancel
Showing results for 
Search instead for 
Did you mean: 

Alpha field - need to extract numbers

Former Member
0 Kudos

Hello,

I am working on a report that has an alpha field in this format:

00-00-00

The users insert numbers where the 0s are. What I need to do is to add the values in the 3 columns. So for example:

03-03-03

A total of 9.

Any ideas on how to approach this? thanks

David

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

As long as your format is always "##-##-##", and there will always be digits and no alpha or special characters in between the hyphens, then this logic will work for you:

local stringvar input := {table.field};

local stringvar array parts := split(input,"-");

val(parts[1]) + val(parts[2]) + val(parts[3])

Former Member
0 Kudos

If this is consistently the format and there is never any difference...

Use the LEFT function to pull the first two

//{@GetLeftTwo}

tonumber (LEFT(,2)) The MID function to get the digits in the middle: //{@GetMiddleTwo} tonumber(MID(,4,2))

The RIGHT function to get the last two digits:

//{@GetLastTwo}

tonumber (RIGHT(,2))

Then simply do a formula to add all three:

//{@SumThemAll}

{@GetLeftTwo} + {@GetMiddleTwo} + {@GetLastTwo}

Former Member
0 Kudos

Thanks I will try this