monkeybarfan
MIS
- Feb 23, 2005
- 116
I have a query and the end user needs to have the postcode field in the dataset in either this format 'AB1 1AB' or this format 'AB12 1AB'
(For the non Brits, UK postcode can be 7 or 8 characters)
Currently the database has them stored as AB11AB or AB121AB i.e. no space separating the high and lower level geographical codes. So I need to insert the spaces in my query (but leave the original data source intact)
I'm guessing a CASE statement and I can probably get away with working back 3 characters from the right (-3?) in terms of where to insert the space but can anyone help me with the code for this?
Also, there are some NULL values but I guess they can just be ignored. There are some nonsense fields where the user/chimp has keyed in the town name instead of the postcode so I may need to clean up some of this too but I can come to that later (Maybe if the length <> 6 or 7 then do not adjust formatting or something).
(For the non Brits, UK postcode can be 7 or 8 characters)
Currently the database has them stored as AB11AB or AB121AB i.e. no space separating the high and lower level geographical codes. So I need to insert the spaces in my query (but leave the original data source intact)
I'm guessing a CASE statement and I can probably get away with working back 3 characters from the right (-3?) in terms of where to insert the space but can anyone help me with the code for this?
Also, there are some NULL values but I guess they can just be ignored. There are some nonsense fields where the user/chimp has keyed in the town name instead of the postcode so I may need to clean up some of this too but I can come to that later (Maybe if the length <> 6 or 7 then do not adjust formatting or something).