Shortening a row of information. (1 Viewer)

New2SQL

Registered User.
Local time
Today, 09:31
Joined
Apr 15, 2005
Messages
19
I have got a set of information that has a mixed bag of names. Some have only a first name but some have a middle name also.

I am looking to shortern the information just to the firstname (i.e. in stead of the results showing "Bill William" as the firstname, i want to just show "Bill").

i tried using the Left function but because the strings are of varied length i need the cut off to be the space between the various names.

Any help would be much appreciated.
 

RV

Registered User.
Local time
Today, 17:31
Joined
Feb 8, 2002
Messages
1,115
Use a combination of the Left and the InStr function:

Code:
Left(columnname, Instr(columnname, " ")-1)

RV
 

New2SQL

Registered User.
Local time
Today, 09:31
Joined
Apr 15, 2005
Messages
19
works a treat but...

...in the row i used this on, some names have no spaces so literally just first name and in the results i get from the expression, i get an #ERROR for those people.

is there a way to get the results from that expression as well as keeping those unaffected as they were?

cheers.
 

workmad3

***** Slob
Local time
Today, 17:31
Joined
Jul 15, 2005
Messages
375
Code:
Iff (InStr(columnname, " "), Left(columnname, Instr(columnname, " ")-1), columnname)
should work (assuming my Iff syntax is correct)
 

RV

Registered User.
Local time
Today, 17:31
Joined
Feb 8, 2002
Messages
1,115
should work (assuming my Iff syntax is correct)

Close :)
Correct syntax is

Code:
Iff (InStr(columnname, " ") = 0, columnname, 
Left(columnname, Instr(columnname, " ")-1))

RV
 

Users who are viewing this thread

Top Bottom