Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
albertramsbottom
Starting Member
4 Posts |
Posted - 2012-04-10 : 08:29:36
|
| I have a table called f2f and a duration filed called "duration" which is in minutes and I need to translate this too hoursmy current sql is:SELECT SUM(duration) /60 as "Total Hours"FROM prefix_f2f_sessionsthis gives me the result as 43.000 hours, I think I would like to chop off the .000 and maybe divide it by 7.5 so I get the daysCan anybody help? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-04-10 : 15:28:03
|
| convert it to int to drop of decimal part or use ROUND(field,0)------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Cheaptrix
Starting Member
1 Post |
Posted - 2012-04-10 : 15:30:58
|
| SELECT CONVERT(INT,((SUM(duration) / 60) / 7.5)) AS Total_DaysFROM .... |
 |
|
|
albertramsbottom
Starting Member
4 Posts |
Posted - 2012-04-11 : 04:39:06
|
| Many thanksIt worked apart from the fact that the convert to interger didnt seem to workI now have SELECT SUM(duration) /60 /7.5 as "Total FTE Days"FROM prefix_facetoface_sessionsWhich does give me the days be it5.73333333Many thanks |
 |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-04-11 : 06:40:31
|
ah -- if you are dividing by a FLOAT or DECIMAL (7.5) the result will be a FLOAT or DECIMAL.If you wanted the number of total days the most natural way would to express it is probably to use FLOOR()Something like DECLARE @duration INTSET @duration = 1000SELECT FLOOR(@duration / 60 / 7.5) Except you'd do:SELECT FLOOR(SUM(duration) /60 /7.5) as "Total FTE Days"FROM prefix_facetoface_sessions Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|