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

Extracting first three numbers of zipcode for search... 1

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
US
Hi there,

I don't know how to search for the answer to this question so please forgive me if it has already been answered.

I am doing a zip code search and need to search on the first three numbers. They enter a five digit zip code. How do I pull out the first three numbers and how do I show that in my SQL statement? It's below (I used 782 as an example). Thanks in advance.

<%set zip=objConn.execute(&quot;SELECT * FROM vwSchedule WHERE (Zip LIKE '782%')&quot;)%>
 
There are several solutions to this:
Code:
myZip = left(Request.Form(&quot;txtZipcode&quot;),3)
myZip = mid(Request.Form(&quot;txtZipcode&quot;),1,3)

you could also use regular expressions, which would be a bit much for this

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top