Subject Re: [firebird-support] formatting number
Author Andrew Gough
----- Original Message -----
From: "Matej Golob" <matej.golob@...>
To: <>
Sent: Tuesday, September 23, 2003 3:03 AM
Subject: [firebird-support] formatting number

> I want to cast number to varchar and fill the leading characters with
> zeros. In oracle I can do "to_char(25, '0000')" and get as result
> "0025". Is there any similar solution for this in firebird?
> (If I just cast number to varchar (cast(25 as varchar(4)) I get char
> "25").

Try something like:

select sright( '0000' || cast( 25 as varchar(4)), 4 ) from rdb$database;

or write an SP 'to_char()' which does it.

Note: you need to have the FB UDF definition for sright() (obviously)

Andrew Gough
LiveNote Technologies Inc.