I have decimal time and I am not able to convert into time.
DECLARE @hours decimal(5,3)
SELECT @hours = 20.30 //20 Hrs and 30 mins
I need the output in below format
Hours 20.5 AS Time (data type)
Below is my code
select cast(hours /24 as datetime)
this code gives output as 20.18 Hrs. However I need 20.5 hrs
Since the decimal part does not really represent the decimal portion of the hour, you need to chop if off and process it separately.
In SQL Server 2012:
Prior to SQL 2012: