Reputation: 11393
If i have workhours
as an int represent the number of hours .
How to convert this number of hours to Time in sql server.
For example :
IF workhours = 8
then the time equivalent value = 08:00:00
Upvotes: 0
Views: 125
Reputation: 82474
Assuming your number of hours is always between 0 and 23, you can do this:
DECLARE @workhours int = 8
SELECT CAST(
RIGHT('0'+ CAST(@workhours as varchar(2)), 2) -- pad with a leading '0'
+ ':00:00' -- add minutes and seconds
As Time)
Upvotes: 1