Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Feb 2006
    Posts
    42

    Unanswered: how to convert numbers into words

    hi could u help me in suggesting how to convert number given in Rs or in $ to words as normal we spell.. ther's is no limit it can be billions or millions.. thanks in advance..

    ----
    chakri

  2. #2
    Join Date
    Nov 2002
    Posts
    272
    Here:
    http://www.planet-source-code.com/vb...d=502&lngWId=5
    is a downloadable set of useful functions, including NumberToWords(),which sounds like what you want.

  3. #3
    Join Date
    Feb 2006
    Posts
    42
    thank q verymuch.. it helpes me a lot
    ----
    chakri

  4. #4
    Join Date
    Feb 2006
    Posts
    42
    could u help me a procedure for words of numbers along with paise in dollars with cents and as well as for Rs and paise also.. In the one u gave me url i dint find for my requirement only for numbers it is there..thnks for ur help
    chakri

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Examples, please?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Feb 2006
    Posts
    42
    if i give 11034.20 $ output: eleven thousand three hundred and thirty four dollars twenty cents.
    if 11034.20 Rs output : eleven thousand three hundred and thirty four rupees twenty paise. there is no limit for the input ofcourse upto octillion.

  7. #7
    Join Date
    Nov 2005
    Location
    San Francisco, CA
    Posts
    506
    Quote Originally Posted by chakri
    if i give 11034.20 $ output: eleven thousand three hundred and thirty four dollars twenty cents.
    if 11034.20 Rs output : eleven thousand three hundred and thirty four rupees twenty paise. there is no limit for the input ofcourse upto octillion.
    I think u can do it in application code very easily,and in reporting tool like crystal report have inbuilt functions to do that.
    Well,I think u want it in sql server...hmmm
    Joydeep

  8. #8
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You should be able to modify this code to add the text "dollars", "cents", "rupees", etc:
    http://www.novicksoftware.com/UDFofW...um_ToWords.htm
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  9. #9
    Join Date
    Feb 2006
    Posts
    42
    I tried this is for dollars, this could be changed for Rs also where in place of 4,7,10,13 and 16 if
    replaced by 3,6,9, and 15 .. and atlast instead of 3,6,9,12 and 15 replace with 3,5,8,11.. its not
    displaying could u modify this dollars code to Rs code and i am trying to get for cents and paise..
    please help me in doing that also..thanks in adv.,
    Code:
    	DECLARE @i int, @temp char(1),  @s VARCHAR(20), @result VARCHAR(255),@N BIGINT /*INPUT */
    	SELECT @s=convert(varchar(20), @n)
    	SELECT @i=LEN(@s)
    	SELECT @result=''
    	WHILE (@i>0)
    	BEGIN
    		SELECT @temp=(SUBSTRING(@s,@i,1))
    		IF ((LEN(@s)-@i) % 3)=1
    		IF @temp='1'
    		SELECT @result=CASE (SUBSTRING(@s,@i+1,1))
    			WHEN '0' THEN 'ten'
    			WHEN '1' THEN 'eleven'
    			WHEN '2' THEN 'twelve'
    			WHEN '3' THEN 'thirteen'
    			WHEN '4' THEN 'fourteen'
    			WHEN '5' THEN 'fifteen'
    			WHEN '6' THEN 'sixteen'
    			WHEN '7' THEN 'seventeen'
    			WHEN '8' THEN 'eighteen'
    			WHEN '9' THEN 'nineteen'
    			END+' '+CASE
    					WHEN ((LEN(@s)-@i)=4) THEN 'thousand '
    					WHEN ((LEN(@s)-@i)=7) THEN 'million '
    					WHEN ((LEN(@s)-@i)=10) THEN 'billion '
    					WHEN ((LEN(@s)-@i)=13) THEN 'trillion '
    					WHEN ((LEN(@s)-@i)=16) THEN 'quadrillion '
    					ELSE ''
    					END+@result
    		ELSE
    		BEGIN
    			SELECT @result=CASE (SUBSTRING(@s,@i+1,1))
    				WHEN '0' THEN ''
    				WHEN '1' THEN 'one'
    				WHEN '2' THEN 'two'
    				WHEN '3' THEN 'three'
    				WHEN '4' THEN 'four'
    				WHEN '5' THEN 'five'
    				WHEN '6' THEN 'six'
    				WHEN '7' THEN 'seven'
    				WHEN '8' THEN 'eight'
    				WHEN '9' THEN 'nine'
    				END+' '+ CASE
    					WHEN ((LEN(@s)-@i)=4) THEN 'thousand '
    					WHEN ((LEN(@s)-@i)=7) THEN 'million '
    					WHEN ((LEN(@s)-@i)=10) THEN 'billion '
    					WHEN ((LEN(@s)-@i)=13) THEN 'trillion '
    					WHEN ((LEN(@s)-@i)=16) THEN 'quadrillion '
    					ELSE ''
    					END+@result
    			SELECT @result=CASE @temp
    				WHEN '0' THEN ''
    				WHEN '1' THEN 'ten'
    				WHEN '2' THEN 'twenty'
    				WHEN '3' THEN 'thirty'
    				WHEN '4' THEN 'fourty'
    				WHEN '5' THEN 'fifty'
    				WHEN '6' THEN 'sixty'
    				WHEN '7' THEN 'seventy'
    				WHEN '8' THEN 'eighty'
    				WHEN '9' THEN 'ninety'
    				END+' '+@result
    		END
    		IF (((LEN(@s)-@i) % 3)=2) OR (((LEN(@s)-@i) % 3)=0) AND (@i=1)
    		BEGIN
    		SELECT @result=CASE @temp
    			WHEN '0' THEN ''
    			WHEN '1' THEN 'one'
    			WHEN '2' THEN 'two'
    			WHEN '3' THEN 'three'
    			WHEN '4' THEN 'four'
    			WHEN '5' THEN 'five'
    			WHEN '6' THEN 'six'
    			WHEN '7' THEN 'seven'
    			WHEN '8' THEN 'eight'
    			WHEN '9' THEN 'nine'
    			END +' '+CASE
    				WHEN (@s='0') THEN 'zero'
    				WHEN (@temp<>'0')AND( ((LEN(@s)-@i) % 3)=2) THEN 'hundred '
    				ELSE ''
    				END + CASE
    				WHEN ((LEN(@s)-@i)=3) THEN 'thousand '
    				WHEN ((LEN(@s)-@i)=6) THEN 'million '
    				WHEN ((LEN(@s)-@i)=9) THEN 'billion '
    				WHEN ((LEN(@s)-@i)=12) THEN 'trillion '
    				WHEN ((LEN(@s)-@i)=15) THEN 'quadrillion '
    				ELSE ''
    					END+ @result
    		END
    		SELECT @i=@i-1
    	END
    	select REPLACE(@result,'  ',' ')+' dollars'
    --------
    chakri

  10. #10
    Join Date
    Feb 2008
    Posts
    11
    HI ,
    I found this post while i was searching for how to convert rupees into words.
    I also have the same function but not able convert it into rupees format .Did u find any solution for this , if u hv then pls help me out .
    Thanks

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    George
    Home | Blog

  12. #12
    Join Date
    Feb 2008
    Posts
    11
    Thnks for the example . But it is for the billion and million and i want it in indian format i.e Rupees , which has differnt logic .In US format ,they count after 3 digits like 100,000,000 while in indian format we count it as 10,00,00,000 i.e 2 digits and in the end three digits which is 100's place . Can u help me out coz i m not able to convert the US format in indian rupees format
    Thanks

  13. #13
    Join Date
    Feb 2008
    Posts
    11
    tHANK U VERY MUCH .I replaced the values with rupees logic and got the desired output .Really thanks

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Glad you found your answer

    Care to share it with us so that future readers may benefit?

    Cheers,
    George
    George
    Home | Blog

  15. #15
    Join Date
    Apr 2007
    Posts
    183
    What about lakhs?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •