Link to home
Start Free TrialLog in
Avatar of SYOUNG
SYOUNG

asked on

Spllit Name Field

I need to split a single database field to LastName and FirstName.  The single database field stores the name as "LastName; FirstName" (semicolon is the delimiter).  I tried using the split function but it is not working for me.  Normally I'd just create a view but this data is coming from a Pervasive database I am not familiar with.
ASKER CERTIFIED SOLUTION
Avatar of UnifiedIS
UnifiedIS

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Bach
Pervasive PSQL doesn't support either SPLIT or INSTR.  However, it does have the LOCATE function, which you can use like this:

LastName -->  LEFT( NameField , LOCATE(NameField, ';') -1 )
FirstName -->  RIGHT( NameField, LENGTH(NameField) - LOCATE(NameField, ';') )

Note that the -1 on the LastName field means that if there is NO semicolon in the field, LOCATE returns 0, and a -1 gets passed to the LEFT function, which will likely spawn an error.  You may have to do a conditional test for the presence of the semicolon before doing that function call.
Avatar of SYOUNG
SYOUNG

ASKER

Split function works great!  The formula works too but I couldn't immediately figure out how to change the syntax for First Name.  Thanks!
Avatar of SYOUNG

ASKER

Split function works great! The formula works too but I couldn't immediately figure out how to change the syntax for First Name. Thanks!