user5015960
user5015960

Reputation:

Converting INT minutes to HOUR in SQL server

I'm writing a view to get hours of holiday count from the minutes.

Minutes data type is INT in the data table

I wrote this but it doesn't work:

DATEPART(HOUR, CONVERT(DATETIME, '00:' + CAST(S.availablevacations AS NVARCHAR(5)) + ':00:000', 114))

COMPILER ERROR: Create View failed because no column name was specified for column 6.

Upvotes: 3

Views: 12566

Answers (1)

Nitin Kumar
Nitin Kumar

Reputation: 898

you can try this

SELECT CONVERT(NUMERIC(18, 2), `TotalMinutes`/ 60 + (`TotalMinutes`% 60) / 100.0)

this will convert you minutes to HH.MM format sql format

Upvotes: 3

Related Questions