Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / General DB Topics / General DB Topics / November 2004

Tip: Looking for answers? Try searching our database.

String Function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maria - 23 Nov 2004 17:38 GMT
Hello,

I am trying to extract part of a string field on a table. It has a
last name and it ends with a comma like "Smith,". I want to extract
the last name and dump the comma. I have this function, but it is not
working properly and it does not extract the comma from the string.
Anyone have any idea of what is going on?

Public Function GetString(InString As String) As String
GetString = IIf(InStr(InString, ",") > 0, Left(InString,
InStr(InString, ",")), InString)
End Function

Any help is appreciated! Thanks
Alan - 23 Nov 2004 17:45 GMT
> Hello,
>
[quoted text clipped - 10 lines]
>
> Any help is appreciated! Thanks

Considering you don't mention what language or db platform is involved, it's
going to be tough for anyone to give you any real help. But, the general
idea is to determine the position number of the comma, and use that as the
upper limit on a substring function. Something like:

GetString = SUBSTR(your_string_field,1,POS(your_string_field,','))

Syntax explained:
substr(field or 'string', start position, end position) and
pos(field or 'string','character(s) you are looking for')
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.