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

 convert a number to decimal Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, January 26, 2010 11:52 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Friday, May 17, 2013 1:15 PM Points: 114, Visits: 186
 Suppose:Declare @mynumber intSet @mynumber = 10299How can I return 102.99 from this or if the variable will be given at runtime, how can I process it to return a number with the first two digits being the decimal.
Post #853868
 Posted Tuesday, January 26, 2010 11:58 AM
 SSC-Dedicated Group: General Forum Members Last Login: Today @ 2:32 PM Points: 32,906, Visits: 26,792
 Faye Fouladi (1/26/2010)Suppose:Declare @mynumber intSet @mynumber = 10299How can I return 102.99 from this or if the variable will be given at runtime, how can I process it to return a number with the first two digits being the decimal.The same way you'd do it manually. Divide by 100.0. --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." For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #853871
 Posted Tuesday, January 26, 2010 12:01 PM
 SSC-Insane Group: General Forum Members Last Login: Today @ 11:17 PM Points: 21,617, Visits: 27,450
 Faye Fouladi (1/26/2010)Suppose:Declare @mynumber intSet @mynumber = 10299How can I return 102.99 from this or if the variable will be given at runtime, how can I process it to return a number with the first two digits being the decimal.As Jeff said:select @mynumber / 100.0
Post #853872

 Permissions