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

split field on :

Status
Not open for further replies.

aspnet98

MIS
May 19, 2005
165
US
I have a data field like this:

9999:9:999:9
XXXX:AAAA:NNNN:NNNN

I need to split the fields into 4 formulas.

1
9999

2
9

3
999

4
9

etc........


The data between the : delimiter can change but their will always be 3 :'s.

Can someone help me with this? The most efficient way to process a lot of data.

I am more familiar with this type of split in SQL server.

CR 8.5

Thanks and best regards.
 
Four formulas, each using the Split function:
[tt]
//@FirstElement
Split({Table.Field}, ":")[1];

//@SecondElement
Split({Table.Field}, ":")[2];
[/tt]
... and so on. You might want to add in some error checking as well to be safe:
[tt]
//@ThirdElement
StringVar Array tmp := Split({Table.Field}, ":");
if UBound(tmp) < 3 then
""
else
tmp[3];[/tt]

-dave
 
Is their a reson you did not use this three times?
Split({Table.Field}, ":")[1];
Split({Table.Field}, ":")[2];
Split({Table.Field}, ":")[3];

Can I use the above three formulas instead?

Why did the third one change?
 
The third was just a demonstration using some error checking. If the field is NULL, or the data isn't formatted, using the formulas in their original formats could generate errors.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top