Click here to Skip to main content
15,921,694 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
how to convert float to timestamp in single select query

for exp.  i have float as 1.251152515236 ,

i want to convert this to datetime and from datetime to timestamp... i.e.   26:11:00
Posted

I found answer
ie.

CONVERT(TIME(0),CONVERT(datetime,1.09796836411745)),

this gives output as 02:21:04
 
Share this answer
 
You mean seconds to a Format i.e hh:mm:ss

try
SQL
SELECT
CONVERT(varchar, DATEADD(ms,  1.251152515236 * 1000, 0), 114)



ref.
http://stackoverflow.com/questions/1262497/how-to-convert-seconds-to-hhmmss-using-t-sql[^]
 
Share this answer
 
Comments
maulikshah1990 18-Mar-15 3:37am    
hi.thanks for reply .. i tried your soln , it say
Database error [8114] Error converting data type varchar to float.
/\jmot 18-Mar-15 3:40am    
which database?
here SQl-Server result "00:00:01:250"
/\jmot 18-Mar-15 3:38am    
how did you tried??
can you show me your code??
maulikshah1990 18-Mar-15 4:36am    
It is actually .crd file made in xml , and i have query inside xml like

<sqlstatement>
<![CDATA[
SELECT USER.LastName,
CONVERT(varchar(25),CONVERT(datetime,SUM(CCData.CONVERSATION_TIME )),114) TimePart from CCData.TABL1

and CONVERSATION_TIME is float with value 1.095214253
and i want output as 26:11:00..
but when i try above , it says Database error: [8114] [Error converting data type varchar to float.]

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