March 30, 2006 at 10:08 pm
Hi
I have a Column say (Tab1.Col_A number (20,5)) store seconds.
I want result in Hours:Minutes:Seconds format
Please advise how to get above outcome.
Note:- At the moment I do Col_A/60 for minutes and Col_A/(60X60) for hours but it is not accurate it some time give 12Hours & 80Minutes.
Wishes
Jawad
March 31, 2006 at 1:55 am
You need to use function to get field in hh:mm format
function D_Time (@S_Time as int)
as
begin
DECLARE @STR INT
DECLARE @QRY VARCHAR(10)
SET @STR=@S_Time
SET @QRY=CAST(@STR/3600 AS VARCHAR(2))+':'
SET @STR=@STR%3600
SET @QRY=@QRY+CAST(@STR/60 AS VARCHAR(2))+':'+CAST(@STR%60 AS VARCHAR(2))
return @QRY
end
March 31, 2006 at 2:59 am
This works for periods less than 1 day.
declare @secs float
set @secs = 15000
select convert(char(8), cast(@secs / 86400 as datetime), 8)
If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.
March 31, 2006 at 3:47 am
thanks
Jawad
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply