Number to Words Conversion

Started by yogeshover 18 years ago6 messagesgeneral
Jump to latest
#1yogesh
yogesh.arora.daffodil@gmail.com

Hello Frnds,

Is there any way to Convert the Number to its equivalent String
( Words)

e.g. 10 to TEN. Urgent require the Answer..

Regards,
Yogesh Arora

#2brian
brian@zijn-digital.com
In reply to: yogesh (#1)
Re: Number to Words Conversion

yogesh wrote:

Hello Frnds,

Is there any way to Convert the Number to its equivalent String
( Words)

e.g. 10 to TEN. Urgent require the Answer..

(column sizes just an example)

CREATE TABLE integer_string (
number SMALLINT NOT NULL,
word VARCHAR(24) NOT NULL
);

brian

#3Bruce Momjian
bruce@momjian.us
In reply to: yogesh (#1)
Re: Number to Words Conversion

yogesh wrote:

Hello Frnds,

Is there any way to Convert the Number to its equivalent String
( Words)

e.g. 10 to TEN. Urgent require the Answer..

We have cash_words:

test=> SELECT cash_words('100');
cash_words
------------------------------------
One hundred dollars and zero cents
(1 row)

but that is money-oriented.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#4Moiz Kothari
moizpostgres@gmail.com
In reply to: Bruce Momjian (#3)
Re: Number to Words Conversion

Hi,

You can use what bruce has suggested and get the value you want.

eg.

select trim(substring(cash_words('1520'), 1, position('dollars' in
cash_words('1520'))-1));

will return you

One thousand five hundred twenty (But ofcourse this eg. does not work for
decimals)

Regards,
Moiz Kothari

On 11/2/07, Bruce Momjian <bruce@momjian.us> wrote:

yogesh wrote:

Hello Frnds,

Is there any way to Convert the Number to its equivalent String
( Words)

e.g. 10 to TEN. Urgent require the Answer..

We have cash_words:

test=> SELECT cash_words('100');
cash_words
------------------------------------
One hundred dollars and zero cents
(1 row)

but that is money-oriented.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB
http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

--
Hobby Site : http://dailyhealthtips.blogspot.com

#5yogesh
yogesh.arora.daffodil@gmail.com
In reply to: Moiz Kothari (#4)
Re: Number to Words Conversion

Hi,

As i am Working for Decimal Formats..... is there any method to do it in
the same way.

On 11/2/07, Moiz Kothari <moizpostgres@gmail.com> wrote:

Hi,

You can use what bruce has suggested and get the value you want.

eg.

select trim(substring(cash_words('1520'), 1, position('dollars' in
cash_words('1520'))-1));

will return you

One thousand five hundred twenty (But ofcourse this eg. does not work for
decimals)

Regards,
Moiz Kothari

On 11/2/07, Bruce Momjian < bruce@momjian.us> wrote:

yogesh wrote:

Hello Frnds,

Is there any way to Convert the Number to its equivalent String
( Words)

e.g. 10 to TEN. Urgent require the Answer..

We have cash_words:

test=> SELECT cash_words('100');
cash_words
------------------------------------
One hundred dollars and zero cents
(1 row)

but that is money-oriented.

--
Bruce Momjian < bruce@momjian.us> http://momjian.us
EnterpriseDB
http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

--
Hobby Site : http://dailyhealthtips.blogspot.com

--
Best Regards,
Yogesh Arora

#6Moiz Kothari
moizpostgres@gmail.com
In reply to: yogesh (#5)
Re: Number to Words Conversion

Hi,

So how would it look like if you say "1520.50" what should it return you
back?

Regards,
Moiz Kothari

On 11/2/07, Yogesh Arora <yogesh.arora.daffodil@gmail.com> wrote:

Hi,

As i am Working for Decimal Formats..... is there any method to do it
in the same way.

On 11/2/07, Moiz Kothari < moizpostgres@gmail.com> wrote:

Hi,

You can use what bruce has suggested and get the value you want.

eg.

select trim(substring(cash_words('1520'), 1, position('dollars' in
cash_words('1520'))-1));

will return you

One thousand five hundred twenty (But ofcourse this eg. does not work
for decimals)

Regards,
Moiz Kothari

On 11/2/07, Bruce Momjian < bruce@momjian.us> wrote:

yogesh wrote:

Hello Frnds,

Is there any way to Convert the Number to its equivalent String
( Words)

e.g. 10 to TEN. Urgent require the Answer..

We have cash_words:

test=> SELECT cash_words('100');
cash_words
------------------------------------
One hundred dollars and zero cents
(1 row)

but that is money-oriented.

--
Bruce Momjian < bruce@momjian.us> http://momjian.us
EnterpriseDB
http://postgres.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

---------------------------(end of
broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

--
Hobby Site : http://dailyhealthtips.blogspot.com

--
Best Regards,
Yogesh Arora

--
Hobby Site : http://dailyhealthtips.blogspot.com