I am trying to write a query to find contacts within a radius of 50 miles and here is the SOQL i have
select Id,Name,mailingStreet,mailingState,mailingCity,mailingPostalCode,mailingcountry,Mailing_Address_Latitude__c,Mailing_Address_Longitude__c,Mailing_Address_Accuracy__c FROM Contact WHERE distance(MailingAddress, geolocation(30.2672, 97.7431), 'mi') < 50 ORDER BY distance(MailingAddress, geolocation(30.2672, 97.7431), 'mi'),mailingCity LIMIT 20];
For some reason i dont get any records even though there are no of contacts with mailing address nearby.
I also created a formula field just to see what what i am getting on the distance. Here is the formula
DISTANCE( GEOLOCATION( Mailing_Address_Latitude__c , Mailing_Address_Longitude__c ), GEOLOCATION( Random_office__Latitude__s , Random_office__Longitude__s ) , 'mi')
The coordinates given in SOQL/formula are of austin.
All the values in the field came out to be > 6000. I thought distance should in miles, but doesnt seem to be logically correct.
I verified 2 addresses in googlemap and its distance was around 7 miles.
Can anyone let know what units the distance method return in? Or what am i doing wrong here?