Firstly I am not an SQL guy (or even pretending to be!) as my background is Active Directory so I apologise in advance if this is a simple answer – 2 hours on Goggle have left me clue less…
I am writing a home application that basically logs GPS movements. I store the movements in a MS 2005 database. I am trying to work out how many HH:MM ago the last GPS signal was received. This value is in UTC time and is stored as follows
gpsTime(datetime) 2006-12-21 18:16:27.000
By using (GETUTCDATE()) – gpsTime I get then how long ago the last report was recived. 1900-01-01 00:01:24.970
But what I really want is just HH:MM 00:01 displayed – i.e. 1 minute ago…
This is what I have so far..
SELECT TOP (5)
(GETUTCDATE()) - gpsTime
As [Time Ago]
FROM TrackerData
WHERE gpsTime > (GETUTCDATE() -0.5) ‘ ignore records over 12 hours old
ORDER BY gpsTime DESC
Thanks in advance for anyone who can help me – this is driving me nuts !!!
I am writing a home application that basically logs GPS movements. I store the movements in a MS 2005 database. I am trying to work out how many HH:MM ago the last GPS signal was received. This value is in UTC time and is stored as follows
gpsTime(datetime) 2006-12-21 18:16:27.000
By using (GETUTCDATE()) – gpsTime I get then how long ago the last report was recived. 1900-01-01 00:01:24.970
But what I really want is just HH:MM 00:01 displayed – i.e. 1 minute ago…
This is what I have so far..
SELECT TOP (5)
(GETUTCDATE()) - gpsTime
As [Time Ago]
FROM TrackerData
WHERE gpsTime > (GETUTCDATE() -0.5) ‘ ignore records over 12 hours old
ORDER BY gpsTime DESC
Thanks in advance for anyone who can help me – this is driving me nuts !!!
Comment