Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Convert GPS from Decimal To DMS

By vevoda.ulath,

Greetings. Just simple script, which someone can find handy. It will do exactly as description said - convert GPS from decimal format to format known as DMS (date-minute-second) .

There are two paramatres

  • @decimalGPS is decimal(20,8) value containg decimal GPS coordinates
  • @isLongitude is bit value expressing whether we are dealing with latitude or longitude

I believe script is self-explaining. The queries are separated, althought they could be probablly shrinked into one, but i preffer readibillity of script before having all written in one row.

 

Simple example:


SELECT dbo.gpsConvertDecimalToDMS(50.4942,0), dbo.gpsConvertDecimalToDMS(14.4481,1) /* 50°29'39.12'' 14°26'53.16'' */

 

Total article views: 799 | Views in the last 30 days: 8
 
Related Articles
SCRIPT

Script to calculate Precision & Scale of a Decimal Value

A script to help you find the Precision & Scale parts of a decimal value.

FORUM

decimal issue

decimal issue

FORUM

Select Decimal

Need Decimal() function

FORUM

Decimal Truncation in division

Decimal Truncation in division

FORUM

Decimal Truncation in division

Decimal Truncation in division

Tags
gps    
math functions    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones