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 2000 Forums
 SQL Server Development (2000)
 Converting a number into hours and minutes

Author  Topic 

pareshmotiwala
Constraint Violating Yak Guru

323 Posts

Posted - 2002-01-28 : 12:42:19
I have an application that generates output in minutes.
Is there a ready to use function that would help me convert these minutes into hours and minutes?

andre
Constraint Violating Yak Guru

259 Posts

Posted - 2002-01-28 : 12:58:41
I don't know of any, but you can use this:

select @minutes/60 AS hours,@minutes%60 AS minutes


Edited by - andre on 01/28/2002 12:59:23
Go to Top of Page

sica
Posting Yak Master

143 Posts

Posted - 2002-01-28 : 13:16:09
If you want tomake it a little bit more complicated:

DECLARE @a INT

SET @A = 160

SELECT @A/60 AS HOURS,
CASE WHEN @A/60 = 0 THEN @A ELSE CEILING(((CONVERT(DECIMAL,@A)/60) - @A/60)*60) END AS MINUTES

Not so appealing as andre solution!!!

Sica

Go to Top of Page
   

- Advertisement -