Page 1 of 1
EXTRACTING FIRST & LAST NAMES
Posted: Mon Aug 26, 2002 3:57 pm
by a_rosenbaum_(Guest)
I HAVE A DATABASE WHICH CONTAINS THE FOLLOWING FIELDS:__LAST NAME (SPACE)FIRSTNAME (SPACE) MIDDLE INITIAL ____I WANT TO EXTRACT ONLY THE FIRST AND LAST NAMES ____HOW DO I DO IT??____THANK YOU____
=> RE: EXTRACTING FIRST & LAST NAMES
Posted: Mon Aug 26, 2002 5:18 pm
by freitas
[updated:LAST EDITED ON Aug-26-02 AT 05:27 PM (EST)]It is harder with blanks instead of , or something else____if the field name were NAME, you could write it with the AT function.____NAME = Newman Alfred E.____The at() tells it where to start or stop in a substring. In my example the BLANK or " " is where it is to start for the first and last name in the substring for the field name of NAME.____The first name would be a little hard, so I will leave that with you to try and figure out. The AT() function can come in very handy. ____Of course if you wanted to just show the first initial of the first name, you could write it like this:____substr(NAME,at(" "+1,name),1)+". "+substr(NAME,1,at(" ",NAME))____This would print the result of A. Newman____The +1 simply tells it to start at the first position past the blank, or the A in alfred.
=> RE: EXTRACTING FIRST & LAST NAMES
Posted: Tue Aug 27, 2002 7:35 am
by kfleming
You can use the WORD() function to do this.__Here is the Help info on WORD()____Returns a word based on its place in a character expression. For example, you can use this function to print/display the first or last word in the expression. ____Syntax:____WORD(C1,N,C2) where C1 is a character expression (string), N is a numeric expression that represents the number or place of the word in the expression, and C2 is an optional character expression that represents the word break character(s), the character(s) marking word separations. If N is a positive number, Report Designer processes the expression starting at the beginning of the string. If N is a negative number, Report Designer processes the expression starting at the end of the string. For example, when N is 1, Report Designer returns the first word of the expression; when N is _1, Report Designer returns the last word of the expression. When N is 0 or greater than the number of words in the character expression, Report Designer returns an empty character field.____If C2 is absent, Report Designer uses the space and hyphen characters to determine word breaks. If you supply C2, Report Designer uses only C2 to determine word breaks (see WDCOUNT for an example).____Examples:____To print/display the last word in a character field DESCRIPTN, create the expression:__WORD(DESCRIPTN, _1)____Sample data:____DESCRIPTN__WORD(DESCRIPTN, _1)__PC Cable Connector__Connector__PC 3 1/2" Diskettes__Diskettes______Kathleen__R&R Support