Convert Degrees Minutes Seconds to Decimal Degrees or Geography
Hopefully somebody already has a nice elegant method for this, and is willing to share. My DB is storing Latitude and Longitude in Degrees/Minutes/Seconds format, in a single string (one for Lat, one for Lon) . Example: Lat = 123456N; Lon = 1234560E. I need to convert these to Decimal, so I can then convert to SQL Geography datatype. Or better yet, directly from DMS to Geography. One caveat: Lat is always 6 numbers, followed by a 'N' or 'S', but Lon could be either 6 or 7 numbers (7 if 100 degrees or more) and if only 6 are listed, then it can be assumed there should be a leading zero. I figured rather than reinvent the wheel ,I would reach out to see if it had already been done.