Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Split integer valuefrom decimal valye Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, August 8, 2011 8:15 PM
 Forum Newbie Group: General Forum Members Last Login: Monday, April 6, 2015 7:25 PM Points: 6, Visits: 46
 i know i can do the floor() on a decimal number and then store that to a variable and subtract it from the original numberexample @a = 2.75@b = floor(2.75)@c = @a - @b (this gives me 0.75)but is there a function that does this in SQL ServerCheers,Chandra
Post #1156497
 Posted Monday, August 8, 2011 8:16 PM
 Forum Newbie Group: General Forum Members Last Login: Monday, April 6, 2015 7:25 PM Points: 6, Visits: 46
 i know i can do the floor() on a decimal number and then store that to a variable and subtract it from the original numberexample @a = 2.75@b = floor(2.75)@c = @a - @b (this gives me 0.75)but is there a function that does this in SQL ServerCheers,Chandra
Post #1156498
 Posted Monday, August 8, 2011 9:36 PM
 Right there with Babe Group: General Forum Members Last Login: Friday, February 6, 2015 9:34 AM Points: 759, Visits: 1,033
 If you can't use convert(), you can always use cast(). BTW, I can't remember how floor() behaves for negative numbers, but I know there's a reason I end up using round() instead.
Post #1156507
 Posted Monday, August 8, 2011 10:03 PM
 SSC-Forever Group: General Forum Members Last Login: Today @ 6:02 PM Points: 42,076, Visits: 39,459
 vchandm23 (8/8/2011)but is there a function that does this in SQL ServerNot in any version of SQL Server that I know of. You're pretty much stuck with doing the math like you did. --Jeff Moden"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column." Helpful Links:How to post code problemsHow to post performance problems
Post #1156510
 Posted Tuesday, August 9, 2011 11:31 AM
 Grasshopper Group: General Forum Members Last Login: Wednesday, May 11, 2016 4:59 AM Points: 21, Visits: 185
 vchandm23:What about using modulus (%)? Like some flavor of the following:select replace(1234.4321 % 1 ,'0.','')
Post #1157078

 Permissions