SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Zip Code Function in SQL Server

    This post relates to this one on zip code proximity - http://www.sitepoint.com/forums/showthread.php?t=157759

    I was able to get this working correctly so that a user can plug in a zip code and a radius and see all the zip codes that fall in the radius. But what I would love to have is a custom function that when I run the query I also get the distance between the zip code I am looking up and the ones it returns.

    Code:
    Select Zipcode, ZipDistance('49415') as Distance
    From Zipcodes
    Where Latitude = 'somenumber' And Longitude = 'somenumber'
    Order By Distance
    The Where clause I know ho to do - it's the function I've been beating my head against the wall on.
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  2. #2
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since each ZIP has a longitude and latitude, surely what you're really asking is how to calculate the distance between two points on the surface of a spheroid?
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  3. #3
    Phil fillup07's Avatar
    Join Date
    May 2002
    Location
    Jacksonville, FL
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And that's not difficult at all...

  4. #4
    SitePoint Evangelist ashattuc's Avatar
    Join Date
    Aug 2002
    Location
    Boise, Idaho
    Posts
    411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was wondering, Westmich, how did you get your list of zip codes with lattitude / longitude coordanants? I have been looking for them, but have been unable to find anything.

    Thanks,
    Chris S.
    Chris S.

    Free Web Scripts - Form generators, AJAX tools and more!
    Micro CMS - A totally free AJAX-based, SEO-ed CMS!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •