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.
| Author |
Topic |
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-06-10 : 15:59:44
|
| I am really confused and I can’t concentrate. Please help me with this easy question:I have a field which contains seconds for example 128460 I need to have how much hours is that in my Query.Please Help me.Sep |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-10 : 16:06:57
|
Divide by 3600, since there are 3600 seconds in every hour. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-06-10 : 16:09:03
|
| I know that but I need to have 35 hours and 41 minutes like this 35.41.Please help me.Sep |
 |
|
|
Sep410
Posting Yak Master
117 Posts |
Posted - 2008-06-10 : 16:33:55
|
| I tried it myself and here it is declare @S as bigintset @S=128460Select @s/3600Select (@s % 3600)/60Sep |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-10 : 16:34:13
|
[code]DECLARE @Seconds INTSET @Seconds = 128460SELECT CAST(@Seconds / 3600 AS VARCHAR(12)) + '.' + STUFF(RIGHT(CONVERT(VARCHAR(8), DATEADD(SECOND, @Seconds, '00:00'), 108), 5), 3, 1, '.')[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-10 : 16:37:37
|
| select datediff(hour,0,dateadd(second,128460,0)),datediff(minute,0,dateadd(second,128460,0))%60MadhivananFailing to plan is Planning to fail |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2008-06-10 : 16:53:57
|
| [code]select Hours_Minutes = datediff(hh,0,DT)+(datepart(mi,DT)*.01)from (select DT = dateadd(ss,128460,0) ) aResults:Hours_Minutes ---------------- 35.41(1 row(s) affected)[/code]CODO ERGO SUM |
 |
|
|
|
|
|
|
|