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 08, 2011 8:15 PM
 Forum Newbie Group: General Forum Members Last Login: Sunday, May 26, 2013 9:06 PM Points: 5, Visits: 40
 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 08, 2011 8:16 PM
 Forum Newbie Group: General Forum Members Last Login: Sunday, May 26, 2013 9:06 PM Points: 5, Visits: 40
 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 08, 2011 9:36 PM
 SSC Eights! Group: General Forum Members Last Login: Friday, October 18, 2013 12:13 PM Points: 951, Visits: 1,011
 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 08, 2011 10:03 PM
 SSC-Dedicated Group: General Forum Members Last Login: Today @ 2:44 PM Points: 34,544, Visits: 28,721
 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." "Change is inevitable. Change for the better is not." -- 04 August 2013(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013Helpful Links:How to post code problemsHow to post performance problems
Post #1156510
 Posted Tuesday, August 09, 2011 11:31 AM
 Grasshopper Group: General Forum Members Last Login: Thursday, April 18, 2013 5:47 AM Points: 20, Visits: 159
 vchandm23:What about using modulus (%)? Like some flavor of the following:select replace(1234.4321 % 1 ,'0.','')
Post #1157078

 Permissions