Click here to Skip to main content
15,566,625 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to SQL Format seconds as HH:MM:SS time

this query .....


SQL
select distinct
E.USERID,
(select min(Convert (TIME,TIMESTAMPS)) from access_event_logs As MINCE
where CAST(MINCE.TIMESTAMPS as DATE)=CAST(E.TIMESTAMPS As DATE) AND MINCE.EVENTID ='In' and MINCE.USERID=E.USERID) as InTime,
(select max(Convert(TIME,TIMESTAMPS)) from access_event_logs As MAXCE
where CAST(MAXCE.TIMESTAMPS as DATE)=CAST(E.TIMESTAMPS As DATE) AND MAXCE.EVENTID ='Out' and MAXCE.USERID=E.USERID) as OutTime
from access_event_logs As E
WHERE E.USERID='012' AND Convert(date,LOCALTIMESTAMP) between '03/2/2014' and '03/02/2014'


output:
012 08:34:29.0000000 14:23:29.0000000


so iwant timestamp i need like this hh:mm or hh:mm:ss
Posted

Try this method.

select convert(varchar(100),GETDATE(),108)
 
Share this answer
 
Comments
Aarti Meswania 9-Apr-14 2:38am    
5+! :)
Maciej Los 9-Apr-14 2:48am    
+5
SQL
SELECT convert(varchar,GETDATE(),108)


Date Time Format In SQL
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900