You need to sign in to do that
Don't have an account?

using distance function
Is it correct if I write- double dist= distance(location__c, geolocation(lat, lng), "km")

No. The DISTANCE function has to be queried. Please see the article here: http://blogs.developerforce.com/developer-relations/2012/10/winter-13-using-apex-and-soql-with-geolocation.html.