Address is
house no-42,sector-39,gautam budh nagar noida-201301 land line-N/A
how to fetch 201301 in separate column name pin code.
Address is
house no-42,sector-39,gautam budh nagar noida-201301 land line-N/A
how to fetch 201301 in separate column name pin code.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vishal YelvePosted Jul 20, 2023, 11:40 AM
Try this
Deepak RawatPosted Jul 20, 2023, 11:39 AM
To fetch the pin code "201301" from the given address and place it in a separate column named "Pin Code," you can use string manipulation or text extraction functions in spreadsheet software like Microsoft Excel or Google Sheets. Here's a step-by-step guide:
Assuming the address "house no-42, sector-39, gautam budh nagar, noida-201301" is in cell A1:
In a separate cell, use the following formula to extract the pin code:
Google Sheets:
This formula will consider that the pin code is always represented by six digits and is separated by a hyphen ("-").
After entering the formula, the cell will display "201301," which is the pin code from the address.
If you want to place the extracted pin code in a separate column (e.g., column B), copy the formula cell and paste it in the desired column for all the addresses you have.
AjeeshPosted Jan 20, 2018, 11:02 AM
Code Provided by Suraj is correct, However I added an additional check condition so that when the zip is not 6 digit number you will get a message like 'Pincode no valid' like below
Sample Demo here :http://sqlfiddle.com/#!6/9eecb7db59d16c80417c72d1e1f4fbf1/18880
Suraj KumarPosted Jan 20, 2018, 5:35 AM
Hello Vinay,
You can write your query as below
DECLARE @str varchar(max) = 'house no-42,sector-39,gautam budh nagar noida-201301 land line-N/A'
SELECT SUBSTRING(@str,(SELECT PATINDEX('%[0-9][0-9][0-9][0-9][0-9][0-9]%',@str)),6) AS PinCode
The output will be
201301
Thanks