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

Extracting Postcode Sectors From Postcodes

Status
Not open for further replies.

beebass

MIS
Feb 19, 2007
14
DE
Hi there

I'm currently using Crystal 9. I need to be able to extract the postcode sector from each postcode that is held in a database. All of the postcodes held have a space between the two seperate parts, i.e. XXXX YYY, or XXX YYY. The postcode sector would be the XXX Y or XXXX Y part of the postcode. Any ideas how I could extract this from the postcode field?

Thanks

Beebass
 
This should work with the scenario's that you provided:

local stringvar input := {table.postal_code};
local numbervar space_pos := instr(input," ");

if space_pos > 0
then left(input,space_pos + 1)
else input

~Brian
 
You need to search for the blank with the Instr function:

If Instr({table.postcode}," ") > 0 then
Left({table.postcode},(Instr({table.postcode}," ") + 1))

MrBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top