Convert number to char

Hello

I need to format numbers when converted to char.
I need to show the number with a precision of 3 and when between-1 and 1 to show the value 0.

ex:
0.234
-0.234
1.220

not de.234

Thanks in advance

I need to show the number with a precision of 3 and when between-1 and 1 to show the value 0.

This?

SQL> with t as (
 select 0.234 n from dual union all
 select -0.234 from dual union all
 select  13.22 from dual union all
 select 1.220 from dual
)
--
--
select n, to_char(n, '990.000')  n2 from t
/
         N N2
---------- --------
      ,234    0.234
    -0,234   -0.234
     13,22   13.220
      1,22    1.220

4 rows selected.

Tags: Database

Similar Questions

  • Convert number to letter of the alphabet?

    Hello

    Is there a LabWindows function to convert a number to an equivalent alphabet?

    I tried something like that...

    char getLetterOfAlphabetByNum (int number) {}
    test if alpha
    If (isalpha (Number) == 0)
    DebugPrintf ("letter number conversion error. Not alphabetic. ») ;
    else {}
    take decimal and convert it to ascii
    Fmt = statusReturned (& letter, "%s < %d »,="" numéro) ;=""> < br=""> if(statusReturned<0)> < br=""> DebugPrintf ("erreur de conversion de nombre en lettre!)) ") \n ») ; < br=""> DebugPrintf ("tempString = %s\n", letter); { < br=""> } < br=""> DebugPrintf ("%d--> %s\n",number,letter);
    return letter; < br="">}

    Thank you!

    Thanks, that was my solution. Passing a 4 gives an a ', for example.

    alphabet letter number < br=""> char getLetterOfAlphabetByNum (int number) {< br=""> number = number + 64;} < br=""> //test if alpha and printable < br=""> if (isgraph (number) == 0) {< br=""> DebugPrintf ("Non-printable character.} \n ») ; < br=""> return; { < br=""> } < br=""> if (isalpha (number) == 0) {< br=""> ("not alphabetic. DebugPrintf} \n ») ; < br=""> return; { < br=""> } < br=""> sprintf (& tempString [0], "%c", number); < br=""> letter tempString = [0]; < br=""> DebugPrintf ("%d--> %c\n",number, letter ');< br="" >="" retour="" lettre ;="">< br="">

  • Convert number to date format

    HI team,

    I have a problem, how we can convert number in date format?
    This is the result of the query.

    SQL > col START_TIME for 999999999999999999999999
    SQL > select start_time in qrtz_triggers;

    START_TIME
    -------------------------
    1364243906000
    1364589406000

    So, I have to change the date format niumber rto.

    My date format as for example: "" Mar 25,2013 20:36:45 ""


    Please suggest me...
    Thank you
    Chavigny

    Published by: 939938 on March 14, 2013 06:39

    This is the number of milliseconds since January 1, 1970.

    SQL> SELECT to_char(to_date('01/01/1970','mm/dd/yyyy')+1364243906000/24/60/60/1000
      2  ,'Mon dd, yyyy hh:mi:ss PM') FROM dual;
    
    TO_CHAR(TO_DATE('01/01/1970','
    ------------------------------
    Mar 25, 2013 08:38:26 PM
    

    So in your query instead of start_time use
    TO_CHAR (to_date (' 01/01/1970 ',' mm/DD/yyyy') + start_time/24/60/60/1000,' Mon DD, YYYY HH: mi: ss PM "")

    Published by: kendenny on March 14, 2013 08:31
    Had used mm instead of e for the minutes.

  • Convert number in time?

    Hello
    I need a query that convert number in time. Please provide a solution.

    Thank you

    Hello
    use following code:

    select lpad(trunc(nvl(&number/60,0),0),2,'0')||':'||lpad(mod(&number,60),2,'0') time
      from dual
    

    PS

  • Convert number of dayes per year

    Please I need help to convert many dayes so far

    I have ID as id

    FT * 09025 * 0000000001 date = 20090125

    FT * date 01171 * 0000000002 = 20100620


    therefore must convert number five after FT as from the
    example * 09025 *.

    map 09-2009
    025 dayes annually number card to 25 jan

    example * 01171 *.
    01 card for 2010
    map number 171 of dayes annually to 20 jun
    (jan + Feb + March + April May) (31 + 28 + 31 + 30 + 31) = plus 151

    171-151 = 20 for next month


    Please need help will be so added filter to informatica card with date

    Published by: user8929623 on July 4, 2010 19:04

    Well, I'm not why when 09 maps to 2009, 01 maps to 2010, not in 2001. Assuming that it should be 2001, use YYDDD format:

    SQL> with t as (
      2             select 'FT*09025*0000000001' id from dual union all
      3             select 'FT*01171*0000000002' from dual
      4            )
      5  select  to_date(substr(id,4,5),'yyddd') dt
      6    from  t
      7  /
    
    DT
    --------
    20090125
    20010620
    
    SQL> 
    

    SY.

  • The implicit conversion of "char to number" or "number of char".

    CREATE TABLE test_table
    (
    NUM NUMBER,
    VCH VARCHAR2 (10)
    );

    INSERT INTO table_test VALUES
    (1, '1') ;

    INSERT INTO table_test VALUES
    (2, '2') ;

    SELECT * FROM test_table WHERE vch = 1;

    When comparing, what type of data is converted into what - all vch values are converted in number or 1 is converted to char '1'?

    Hello

    Welcome to the forum!

    The answer to your question is in the predicate explain plan section:

    filter predicates: to_number ("VCH") = 1

    Best regards
    Nikolai

  • How to convert number in date and time in labview

    Hi all

    I have a hexadecimal string and converted into a number. Now this number to display in the format of timestamp. Uses the format of the time Unix.

    By using this link, I can convert this number to timestamp.  http://www.UnixTimeStamp.com/index.php

    But how it should be done in LabVIEW? I know it may be simple, but please help.

    I enclose my VI for referance.

    Thank you

    Manisha

    Hi Man_Can,

    You can add the origin of UNIX timestamp to your number:

  • Convert number to string in function, spell training?

    I saw a few posts asking how to convert a hexadecimal string to a number, but I saw nothing in regard to going the other way - how to convert a new number into a hexadecimal string. Can TestStand convert a number to a hexadecimal string in a function?

    Here's what I'm trying to do (Locals.CryTuneHex is a string containing a hexadecimal value represented and Locals.Freq_Meas is a digital):

    Locals.CryTuneHex = Val ("0 x" + Locals.CryTuneHex) + round (((320000 - Locals.Freq_Meas)/0.065),4)

    or in simpler terms:

    Locals.HexString = Locals.DecimalNumber

    I need to convert the right side of the equation (which is a decimal number) to a hexadecimal string in order to to store in the string variable on the left side of the equation. Is this possible? In my view, there are a Str() operator to convert to a string, but I need in hex, not only a string representation of the decimal number.

    Thank you!

    Pass a format to Str, like the people of the country. HexString = str (Locals.Number, "%x")

    To play with format strings, create a local number, right-click and select the Digital Format, and then select Hex to Type and watch how the format string varies when you change options.

  • CONVERT NUMBER TO STRING

    Hello

    Anyone know how to convert a number to a string

    for example I need to convert the number 1-9999 to a string, but the number less than 1000 in the string should appear as 0900 900, the number hit 1000should add a befor 0 in front of the number in the string.

    can someone show me how to do?

    Like this

    The VI below is in Labview 8.0

  • Convert C unsigned char in a string

    I'd like to convert this C code in LabVIEW.  I'm a little confused on how to load the SendData in my .so or .dll (for windows).  The supplied CPCI75C3_SER_TransmitBuffer function takes in a string. How to convert this table to unsigned char in string?

    unsigned char SendData [8];

    ...

    for (i = 0; i< 8;="">
    SendData [i] = (unsigned char) i;           / * incremental data * /.

    / * Add a delay here for the receiver is ready * /.
    nai_msDelay (500);

    nNumWordsSend = i;
    printf ("\nSending %d words... (', nNumWordsSend);
    status = CPCI75C3_SER_TransmitBuffer (map, nMod, nChan SendData & nNumWordsSend); / * send data * /.

    Seems to me that call library function node is configured correctly.

    EDIT: you updated your post after I replied.  An unsigned char is identical to an unsigned byte (U8) but how you configured it now is fine, no need so that she takes a byte array, unless I misunderstand what you're asking.

  • Number in char format

    Hi all

    question: How can I format a number of tank, a number like this

    12345.2 is 0012345.20 (length 10 included char decimal point)

    12345 for 0012345.00

    Select LPAD (to_char (numb1, '0000000 D 00'), 10, '0') aa.

    LPAD (to_char ((156879.2 *100)/100), 10, '0') bb

    Double;

    Thanks in advance

    Hello

    user560737 wrote:

    Hi all

    question: How can I format a number of tank, a number like this

    12345.2 is 0012345.20 (length 10 included char decimal point)

    12345 for 0012345.00

    Select LPAD (to_char (numb1, '0000000 D 00'), 10, '0') aa.

    LPAD (to_char ((156879.2 *100)/100), 10, '0') bb

    Double;

    Thanks in advance

    You almost had it.

    To_char, by default, leaves room for a sign less.  Use "FM" in the format string to change this:

    SELECT TO_CHAR (numb1, 'FM0000000D00') AS aa

    FROM table_x - double is not a column called numb1

    ;

  • Convert number to Varchar for printing the Type of table in a loop error: PLS-00306:

    Hello

    I am trying to print a number of the Table that I get from a ref cursor But cannot convert the number to Varchar to print. What I'm doing wrong here

    Thank you

    Ken

    OUT_REFCURSOR FETCH BULK COLLECT INTO theTBL_RCRD_ID ;

    So THAT (theTBL_RCRD_ID IS NOT NULL)

    LOOP

    strRCRDID: = TO_CHAR (onTBL_RCRD_ID (indx), "99999");    -This line throws error message

    dbms_output.put_line (strRCRDID);

    INDX: = indx + 1;

    END LOOP;

    • Error: PLS-00306: wrong number or types of arguments in the call to "TO_CHAR.

    Try this...

    strRCRDID: = TO_CHAR (outTBL_RCRD_ID (indx). RCRD_ID, "99999");

  • Carve out a number in char value

    Hello

    I have a number of 0,0027 and need to convert the value of character 0,0027, I tried to use under query, but the value est.0027 with no previous 0 to the decimal

    Select substr (to_char (0.0027), 1, 6) of double

    How can I get the result 0,0027.

    Thank you

    Try below

    SQL > select to_char ('0.0027 ','990.9999 ') of double

    2.

    TO_CHAR ('0.0027 ','990.9999 ')

    ----------------------------

    0,0027

    SQL >

  • Convert number to HH24:MI:SS

    Hello

    I use the version of database oracle 11.2.1 and want convert a number to a few minutes to the date format HH24:MI:SS

    I use the following syntax, but this does not include seconds, returns format HH24

    Select the FLOOR (165,44 / 60). ':' || TO_CHAR (MOD (165,44, 60), "FM00")

    of the double

    Is it possible to add a second HH24:MI:SS?

    The research of this

    SQL > select numtodsinterval (165,44, 'MINUTE')
    2 double;

    NUMTODSINTERVAL(165.44,'MINUTE')
    ------------------------------------------------------
    + 02:45:26.400000000 000000000

    SQL >

  • Convert number to number (11.2)

    How can I convert to number (11.2)

    I tried with the watch below how, but the invoice_total data type as number. But I want it to be Number (11.2)
     CAST (NULL AS VARCHAR2 (2 BYTE)) AS CARD_NO,
                CASE
                   WHEN A.cur_code IN ('JPY', 'HUF')
                   THEN
                      CAST (SUM (sold_amount) *1  AS NUMBER (11, 2)) 
                   ELSE
                      CAST (SUM (sold_amount) / 100 AS NUMBER (11, 2)) 
                END
                   AS invoice_total,

    Hello
    You must give the CASE statement in the CAST:

    cast(case ... end as NUMBER(11, 2)) as invoice_total
    
    create or replace view test_view as
    select cast(
      case
        when dummy = 'x' then 1
        else 0
      end as number(11,2)) col
    from dual;
    
    desc test_view
    Name Null Type
    ---- ---- ------------
    COL       NUMBER(11,2) 
    

    Published by: Ivan Blanarik on February 13, 2013 12:30

Maybe you are looking for