Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts 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: 831 | Views in the last 30 days: 1
 
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