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 |
|
dcw0405
Starting Member
1 Post |
Posted - 2012-09-06 : 17:44:10
|
| Hello!I have the following (LONG) expression in my SELECT statement, I need help because it runs, but it's giving me a whole number, not the decimal format I need. Because it's so long and tedious, I'm having a hard time knowing what to put where and if it's even possible. The result is giving me an INT and I want it to four decimal places. If anyone has any tips, I'd be SO grateful! Thank you!CREATE TABLE #bdaymoney (name_n CHAR(12), svc_d CHAR(11), eff_d CHAR(11), time INT) INSERT #spe_downgrade SELECT sq.name_n, convert(char(10), sq.svc_d, 101), convert(char(10), ud.eff_d, 101), CASE WHEN day(ud.eff_d) < day (sq.svc_d) THEN (((year(ud.eff_d) - year(sq.svc_d)) + (month(ud.eff_d)-month(sq.svc_d)) / 12)-0.0833) ELSE ((year(ud.eff_d) - year(sq.svc_d)) + (month(ud.eff_d)-month(sq.svc_d)) / 12) END AS timeSo running this, if eff_d = 06/27/2010 and svc_d = 12/07/1999, I want it to produce 10.5000, but right now it just produces 11. I know this is confusing but any help would be appreciated for this n00b. Thank you!! |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2012-09-06 : 19:00:24
|
| If you do integer math you get integer results. Try changing the 12 to 12.00 or someting that is not an integer. FOr example:SELECT 100/12, 100/12.0 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|