locked
GPS coordinate into degrees, minutes, seconds RRS feed

  • Question

  • Good day all,

    I would like to convert my GPS coordinate in an SQL table into the format degrees, minutes seconds. Example:

    36.31985 = 36°19'11.46" N

    95.600617 = 95°36'02.22" W

    Please assist,

    Many thanks

    Regards

    Tuesday, February 23, 2016 7:53 AM

Answers

  • Hello,

    That is only a simple calculation:

    DECLARE @coordinate numeric(12, 8);
    SET @coordinate = 36.31985;
    
    DECLARE @degree int, @minutes int, @secondes numeric(12 ,8);
    
    SET @degree = CONVERT(int, @coordinate);
    SET @coordinate = (@coordinate - @degree) * 60.0;
    SET @minutes = CONVERT(int, @coordinate);
    SET @secondes = (@coordinate - @minutes) * 60
    
    SELECT @degree, @minutes, @secondes


    Olaf Helper

    [ Blog] [ Xing] [ MVP]

    Tuesday, February 23, 2016 11:24 AM