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 |
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2012-08-10 : 05:52:49
|
Hi all,why my ceiling doesn't return 9.declare @Months intset @Months=100select ceiling(@Months/12) 100/12=8.3333 Output show: 8.Please advise.Thank you.Regards,Micheale |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-10 : 06:03:01
|
It's called Integer Division.Try select ceiling(@Months/12E) N 56°04'39.26"E 12°55'05.63" |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-08-10 : 06:04:37
|
you are using integer division -- i,e DIVExampleDECLARE @months INT = 100DECLARE @divisor INT = 12SELECT @months / @divisor Returns 8Divide by a float or numeric to get the result you want.DECLARE @months INT = 100DECLARE @divisor FLOAT = 12SELECT @months / @divisor Returns 8.33333333333333Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. http://nosqlsolution.blogspot.co.uk/ |
 |
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2012-08-10 : 06:09:26
|
Thank you very much.How can i get just the part of decimal. Output i want is 0.3333.I want to get the result to tell me 100 months = 8 year & 4 month.Please advise. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-10 : 06:13:31
|
Use Modula!SELECT 100 / 12 AS [Years], 100 % 12 AS [Months] N 56°04'39.26"E 12°55'05.63" |
 |
|
micnie_2020
Posting Yak Master
232 Posts |
Posted - 2012-08-10 : 07:24:04
|
Thank you to all. |
 |
|
|
|
|