Jedidia
asked on
T-SQL and Rounding
I have the following t-sql...
SUM(DATEDIFF(MINUTE, CONVERT(datetime, tblProduction.startDate, 101) + ' ' + CONVERT(datetime, tblstarttime.time, 108), CONVERT(datetime, tblProduction.endDate, 101) + ' ' +
CONVERT(datetime, tblendtime.time, 108)) / 60) AS totalhours
It calculates the correct # of minutes, but when I /60 to get the hours, it rounds down.
How should I update this so when 30 minutes is calculated, I get 0.5 hours etc.
SUM(DATEDIFF(MINUTE, CONVERT(datetime, tblProduction.startDate, 101) + ' ' + CONVERT(datetime, tblstarttime.time, 108), CONVERT(datetime, tblProduction.endDate, 101) + ' ' +
CONVERT(datetime, tblendtime.time, 108)) / 60) AS totalhours
It calculates the correct # of minutes, but when I /60 to get the hours, it rounds down.
How should I update this so when 30 minutes is calculated, I get 0.5 hours etc.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.