Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you convert to Time in SQL

Status
Not open for further replies.

NKOS13

Technical User
Mar 23, 2009
97
ZA
1. l have a column which say AUDITTIME and the value for time is numeric like below:
AUDTTIME
8042131
8042131
8042131
12171217
13315139
12181989
12184103
7423235

This does not represents this format of time (13:45:62)If l manage to get the time in any type of user readable that would be perfect. l just want to convert the this format of time to a real readable time format (eg 13:45 or 13H45 62 sec)
 
Assuming that the integer given represents number of seconds since midnight, the following should get you to where you need:
Code:
DECLARE @seconds int;
SET @seconds = 12171217;

SELECT DATEADD(second, @seconds, '20090101'),CONVERT(char(5), DATEADD(second, @seconds, '20090101'), 108);

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top