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
 Convert Minutes to Decimal

Author  Topic 

nerdygirl61
Starting Member

21 Posts

Posted - 2012-05-03 : 17:49:36
What I need to do is convert minutes into a decimal format.

If I have 90 minutes I want to get 1.5, Is there some simple way to do this?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-03 : 18:02:09
declare @i int

set @i = 90

select convert(decimal(10, 2), @i/60.0)

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

nerdygirl61
Starting Member

21 Posts

Posted - 2012-05-03 : 18:33:15
Thank you Tara, for some reason I was thinking that would convert it to 1.30.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-03 : 18:44:52
It's just math. 90 divided by 60 is 1.5. I added .0 to 60 so that rounding doesn't occur, otherwise SQL would say 1 for that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -