Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools


Click here to copy the following block
declare @decimal_val float, @divisor int, @decimal_char varchar(30), @int_val int,
   @after_decimal_char_val varchar(30), @dot_index int
select @decimal_val = 12.6, @divisor = 5, @decimal_char = convert(varchar, @decimal_val),
   @dot_index = charindex('.', @decimal_char),
   @int_val = convert(int, substring(@decimal_char, 1, @dot_index - 1)),
   @after_decimal_char_val = substring(@decimal_char, @dot_index + 1,
                   len(@decimal_char) - @dot_index)
select Convert(varchar, (@int_val % @divisor)) + '.' + @after_decimal_char_val

go
declare @decimal_val decimal(3, 1)
SELECT @DECIMAL_VAL = 12.6
select WHOLE_VAL = convert(int,substring(convert(varchar,@decimal_val), 1,
           charindex('.', convert(VARCHAR,@decimal_val))-1)),
   FRAC_VAL = @decimal_val -convert(int,substring(convert(varchar,@decimal_val), 1,
           charindex('.', convert(VARCHAR,@decimal_val))-1))


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.