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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select convert(datetime, 184, 108)

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2010-10-19 : 09:05:47
why is select convert(datetime, 184, 108)

returning 1900-07-04 00:00:00.000

and not the minuts field and what can i change it to to make it return the 184 just in the minutes field (should return 03:04)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-19 : 09:21:44
select convert(datetime,0)
is giving 1900-01-01 00:00:00.000
Hence 184 is giving what you got.

declare @time int
set @time = 184

select right('00'+cast((@time / 60) as varchar(2)),2) + ':' + right('00'+cast((@time % 60) as varchar(2)),2)

Found here: http://www.sqlservercentral.com/Forums/Topic656902-338-1.aspx#bm656914


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-10-19 : 09:29:18
SELECT CONVERT(CHAR(8), DATEADD(MINUTE, 184, 0), 8)



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

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2010-10-19 : 09:38:14
thanks :)
Go to Top of Page
   

- Advertisement -