Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Convert Hours standing in the Number Format to Dec
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 02/27/2014 :  08:06:55  Show Profile  Reply with Quote
Hello Friends,

How do I conveter a field that is in hours in decimal format to number?

Ex: 8:48 = 8.48

Convert 8.48 to decimal 8.8

Could someone help me?

In (Som, Ni, Yak)

17689 Posts

Posted - 02/27/2014 :  08:14:43  Show Profile  Reply with Quote
what is the data type of the 8:48 time ?

declare	@time 		time,
	@decimal	decimal(10,2)

select	@time		= '8:48',
	@decimal	= 8.48

select	@time, datepart(hour, @time) + datepart(minute, @time) / 60.0

select	@decimal, floor(@decimal) + (@decimal * 100 % 100 / 60.0)

Time is always against us

Go to Top of Page

Starting Member

2 Posts

Posted - 02/27/2014 :  08:25:39  Show Profile  Reply with Quote
I need to convert 8.48 to 8.8 (decimal).
Go to Top of Page

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 02/27/2014 :  12:17:38  Show Profile  Reply with Quote
Here is one way:
DECLARE @Foo DECIMAL(18,2) = 8.48
SELECT FLOOR(@Foo) + (((@Foo - FLOOR(@Foo)) * 100) / 60.0)

EDIT: Doh, I didn't realize that Khatn already solved the issue.

Edited by - Lamprey on 02/27/2014 12:18:40
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000