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
 datetime problem

Author  Topic 

Asdzxc1986
Starting Member

14 Posts

Posted - 2009-12-22 : 05:03:51
need to convert datetime to float.

how can I do it with convert function?

DECLARE @SUM float
DECLARE @Unload_Time datetime

??? I suppose it's incorrect, because doesn't give any results.

UPDATE Route set SUM=convert(float, @Unload_Time, 120) where id<>0

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-12-22 : 05:14:50
UPDATE Route
set [SUM] = convert(float, @Unload_Time)
where id <> 0



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-22 : 05:16:31
Hi

You expect this..?

SELECT CAST(CONVERT(DATETIME, GETDATE(), 120) AS FLOAT)
SELECT CAST(CONVERT(DATETIME, GETDATE(), 103) AS FLOAT)


sorry i think no need to use convert

-------------------------
R...
Go to Top of Page

Asdzxc1986
Starting Member

14 Posts

Posted - 2009-12-22 : 05:30:57
How to write it?

I suppose it's incorrect???
Update ROUTE set SUM=CAST(CONVERT(DATETIME, @time_unload, 120) AS FLOAT) where id<>0

quote:
Originally posted by rajdaksha

Hi

You expect this..?

SELECT CAST(CONVERT(DATETIME, GETDATE(), 120) AS FLOAT)
SELECT CAST(CONVERT(DATETIME, GETDATE(), 103) AS FLOAT)


sorry i think no need to use convert

-------------------------
R...


Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-12-22 : 08:38:01
Do it exactly like Peso showed you. Notice how he put [] around the word SUM? That tells SQL to use the column called SUM and not the SUM function. You may also need to put the table name in brackets as well.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

Asdzxc1986
Starting Member

14 Posts

Posted - 2009-12-22 : 08:47:05
Thanks, it works!!!
Go to Top of Page
   

- Advertisement -