Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to convert float to timestamp in single select

Author  Topic 

mshah90
Starting Member

3 Posts

Posted - 2015-03-18 : 02:30:45
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

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2015-03-18 : 02:58:14
[CODE]
DECLARE @y float = 1.251152515236
SELECT @y, CONVERT(datetime,@y,120) DateAndTime, CONVERT(varchar(25),CONVERT(datetime,@y),114) TimePart
[/CODE]

--
Chandu
Go to Top of Page

mshah90
Starting Member

3 Posts

Posted - 2015-03-18 : 03:17:51
Hi
thanks i will try but what is timepart ?? do we need that ?or it can be like convert() AS ConvTime (i.e. userdefined)
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2015-03-18 : 03:22:19
yes... Here, TimePart column is to extract only the TIME of datetime value

--
Chandu
Go to Top of Page

mshah90
Starting Member

3 Posts

Posted - 2015-03-18 : 04:42:20
It is actually .crd file made in xml , and i have query inside xml like


<![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.]
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2015-03-19 : 02:58:23
quote:
Originally posted by mshah90

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


What is the logic behind your output?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2015-03-19 : 05:40:53
SELECT DATEADD(SECONDS, 1.095214253 * 86400, '18991231 00:00:00');



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -