Convert number to alphabet

hi
i need help in converting number to alphabet
for example 4 to D, 2 to B, etc
thank you for helping
best regards
andors

private String Number2String(int number, bool isCaps)
    Char c
= (Char)((isCaps ? 64 : 96) + number);
    return c.ToString();
No point in doing - 1.
If you want 0 to be A then start at 65 for caps, 97 for lower.
Edit:
After some messing around, I've come up with the perfect method:
public static string numberToAlpha(long number, bool isLower = false)
string returnVal = "";
char c = isLower ? 'a' : 'A';
while (number >= 0)
returnVal = (char)(c + number % 26) + returnVal;
number /= 26;
number--;
return returnVal;

Similar Messages

  • Convert number to letter of alphabet?

    Hi,
    Is there a LabWindows function for converting a number to an alphabet equivalent?
    I was trying something like this...
    char getLetterOfAlphabetByNum(int number){
        //test if alpha
        if(isalpha (number)==0)
            DebugPrintf ("Error converting number to letter. Non-alphabetic.");
        else{
            //take decimal and convert to ascii
            statusReturned=Fmt (&letter, "%s<%d", number);
            if(statusReturned<0)
                DebugPrintf ("Error converting number to letter!\n");
            DebugPrintf ("tempString = %s\n", letter);
        DebugPrintf ("%d --> %s\n",number,letter);
    return letter;
    Thanks!
    Solved!
    Go to Solution.

    It seems to me that you could simplify your code this way:
    //number of alphabet to letter
    char getLetterOfAlphabetByNum (int number)
        number += 64;
        //test if alpha
        if (!isalpha (number)) {              
            DebugPrintf ("Non-alphabetic.\n");
            return 0;
        return (char)number;
    I excluded the test for printable characters as is it overcome by test for alphabetic.
    Also, be warned that passing numbers from 33 to 58 returns lowercase letters.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to convert number datatype to raw datatype for use in data warehouse?

    I am picking up the work of another grad student who assembled the initial data for a data warehouse, mapped out a dimensional dw and then created then initial fact and dimension tables. I am using oracle enterprise 11gR2. The student was new to oracle and used datatypes of NUMBER (without a length - defaulting to number(38) for dimension keys. The dw has 1 fact table and about 20 dimension tables at this point.
    Before refining the dw further, I have to translate all these dimension tables and convert all columns of Number and Number(n) (where n=1-38) to raw datatype with a length. The goal is to compact the size of the dw database significantly. With only a few exceptions every number column is a dimension key or attribute.
    The entire dw db is now sitting in a datapump dmp file. this has to be imported to the db instance and then somehow converted so all occurrences of a number datatype into raw datatypes. BTW, there are other datatypes present such as varchar2 and date.
    I discovered that datapump cannot convert number to raw in an import or export, so the instance tables once loaded using impdp will be the starting point.
    I found there is a utl_raw package delivered with oracle to facilitate using the raw datatype. This has a numbertoraw function. Never used it and am unsure how to incorporate this in the table conversions. I also hope to use OWB capabilities at some point but I have never used it and only know that it has a lot of analytical capabilities. As a preliminary step I have done partial imports and determined the max length of every number column so I can alter the present schema number columns tp be an apporpriate max length for each column in each table.
    Right now I am not sure what the next step is. Any suggestions for the data conversion steps would be appreciated.

    Hi there,
    The post about "Convert Numbers" might help in your case. You might also interested in "Anydata cast" or transformations.
    Thanks,

  • Problem in converting number to character

    Hi All,
    In my report there is number field called <?LINE_TOT_AMOUNT?>. In the next line i want to display that amount in words. I tried using
    <?xdofx:to_char(LINE_TOT_AMOUNT)?>
    but the output is same as the <?LINE_TOT_AMOUNT?>. Can any one help in solving this?

    look at TO_CHAR (number)
    if LINE_TOT_AMOUNT is number then to_char(LINE_TOT_AMOUNT) in string
    it's not display that amount in words
    it's only format row
    if you wnat to convert number to words
    plz see Re: Conversion of number to word

  • Function module for converting number to exponential???

    Hi All
      please tell me Function module for converting number to exponential.
    Deepak

    try:
    REPORT Zconvertf.
    parameters p1 type p decimals 2 default '4711.99'.
    data f1 type f.
    move p1 to f1.
    write: / p1, f1.
    hope that helps
    Andreas

  • I want to convert number to hours in oracle 10 like this.

    Dear All
    Some can help me
    I want to convert below MS-SQL query in oracle 10g. please help me.
    for eg:
    Select numasdate,
    Cast(numasdate / 60 as Varchar) + ' hours ' +
    Cast(numasdate % 60 as Varchar) + ' minutes'
    as [TotalHoursAndMinutes]
    From
    #SampleTable
    Output:
    9436 157 hours 16 minutes
    537 8 hours 57 minutes
    9323 155 hours 23 minutes
    12525 208 hours 45 minutes
    Edited by: Parwez on Jan 1, 2013 5:33 AM

    I want to convert number to hours in oracle 10g like this.
    537 8 hours 57 minutes
    9436 157 hours 16 minutes
    12525 208 hours 45 minutesTry this...
    Ranit>> with xx as(
      2      SELECT 537 num from dual UNION ALL
      3       SELECT 9436 num from dual UNION ALL
      4       SELECT 12525 num from dual
      5  )
      6  select
      7       num,
      8       FLOOR(num/60)||' hrs' as "hrs",
      9       MOD(num,60)||' minutes' as "minutes",
    10       FLOOR(num/60)||' hrs  '||MOD(num,60)||' minutes' as "Hours.Mins"
    11  from xx;
           NUM hrs                                          minutes                                          Hours.Mins                                                                                                        
           537 8 hrs                                        57 minutes                                       8 hrs  57 minutes                                                                                                 
          9436 157 hrs                                      16 minutes                                       157 hrs  16 minutes                                                                                               
         12525 208 hrs                                      45 minutes                                       208 hrs  45 minutes                                                                                                Edited by: ranit B on Jan 1, 2013 6:51 PM
    --- Hey John... I just did it and saw your hint now !!!

  • Convert number of dayes per year to data

    Please i need help in Convert number of dayes to date
    I have ID's like id
    FT*09025*0000000001 date=20090125
    FT*01171*0000000002 date=20100620
    so should convert first five number after FT to date
    example *09025*
    09 map to 2009
    025 number of dayes per year map to 25 jan
    example *01171*
    01 map to 2010
    171 number of dayes per year map to 20 jun
    (jan+feb+mar+apr+may)=(31+28+31+30+31)=151
    171-151=20 for the next month
    Please need help so will added filter to informatica map with date
    Edited by: user8929623 on Jul 4, 2010 7:04 PM

    Well, I do not follow why when 09 maps into 2009, 01 maps into 2010, not into 2001. Assuming 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.

  • How to convert number to string in java

    hi how can i convert number to string in java
    something like
    public void Discription(Number ownerName){
    String.valueOf(ownerName);Edited by: adf009 on 2013/04/08 7:14 PM

    Yet another way of doing it is: ownerName.toString().
    If you are working in and IDE such as Netbeans or Eclipse, type a period after the object name. Wait a second or so. Eclipse/Netbeans Intellisense will show you a list of functions that object provides that you can choose from. toString() is one of them.

  • Convert number to simplified chinese number (daxie)

    I need to print simplified chinese number (daxie). Do SAP have standard function module or BAPI to convert number into simplified chinese number (daxie). for example:
    1001 = &#22777;&#20191;&#38646;&#22777;&#20803;
    111 = &#22777;&#20336;&#22777;&#25342;&#22777;&#20803;
    Thanks.

    Hi,
      Use FM :SPELL_AMOUNT

  • How to add date with month after convert number to month?

    How to add date with month after convert number to month?
    Month Date Result
    24 21/11/09 24*(21/11/09)
    I want to add both the column and result should be 21/11/11
    Thanks
    Nihar

    Hmm,
    Because, you are using YYYY for '09'.
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(to_date('10/01/09','DD/MM/RRRR'),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(TO
    10/01/2009
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(to_date('10/01/09','DD/MM/YYYY'),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(TO
    10/01/0009Or with Add_months
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(add_months(to_date('10/01/09','DD/MM/YYYY'),36),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(AD
    10/01/0012
    SQL> ed
    Wrote file afiedt.buf
      1* select to_char(add_months(to_date('10/01/09','DD/MM/RRRR'),36),'DD/MM/YYYY') from dual
    SQL> /
    TO_CHAR(AD
    10/01/2012-Arun

  • Converting number in words

    Hi,
    I want to convert number in words and get the output through a query.
    For example :if the value in row is 1311 then I want the query to return it like one thousand three hundreds and eleven.
    Any help is highly appreciated.
    Cheers

    It could be better indeed, scope is larger, but problem with 0 still exists.
    SQL> select to_char(to_date(0,'J'), 'JSP') as converted_form from dual;
    select to_char(to_date(0,'J'), 'JSP') as converted_form from dual
    ERROR at line 1:
    ORA-01854: julian date must be between 1 and 5373484
    SQL> Better to build function as showed by Tom Kyte in the link given earlier.
    Nicolas.

  • How to convert number in to Date in column formula in analyses

    Hi All,
    I have one requirement, it needs Number conversion in to date.
    I wrote like this cast(tablename.columnname as Date)
    I'm getting error [nQSError: 22025] Function Cast is called with an incompatible type. (HY000)
    column has datatype Number(10,0).
    Please any one help me.
    Thanks,
    Ashwini K

    Hi,
    Please refer below links.
    http://satyaobieesolutions.blogspot.in/2013/06/dateformat-converting-using-evaluate.html
    http://satyaobieesolutions.blogspot.in/2013/06/date-format-change.html
    Hope this help's
    Thanks,
    Satya Ranki Reddy

  • Program or FM to convert number of days into a CalDay format (ddmmyyy)

    Hi ABAP friends,
    I input calendar day values via a popup calendar from a spreadsheet to BW. So, the values that are populated in BW are the numbers, and not the date.
    For ex. when user selects a calendar day for ex. 11-April-2010, the value in excel is stored as 40279 (which is the number of days starting from 01-Jan-1900) and this is the value that gets stored in BW once we save the data.
    I'm looking for a function module or method or whatever that converts the above number (40279) into CalDay and writes it to the 0CALDAY infoobject ???
    Please help,
    Thanks,
    Venkat

    Thanks Pranaam.
    Two things:
    1. I cannot find this FM. It says FM doesn't exist. SE37 -->  HR_HK_DIFF_BT_2_DATES
    2. My requirement is actually reverse as you explained. I can certainly hard code the starting date: 01011900, but here the input should be the number of days. and I need the date (date2 in your ex.) based on the no. of days entered.
    I found another FM which does exist in my BW system. That is: FIMA_DAYS_AND_MONTHS_AND_YEARS
    Based on "From" & "To" dates, it outputs the number of days.
    But my requirement is:
    Based on the starting date (i.e. always 01011900) and number of days, it should give me the "To" date value.

  • How to convert number field into time

    Hi
    I have made a form for storing of private dialed calls from different extensions. To store call duration i have assigned a number field which is storing following type of data
    1.34
    1.19
    37.29
    1.47
    In above mentioned data decimals are seconds and left side is minutes.
    Now the requirement is that if second is > 30 then 1 minute should be added in minutes else 30 seconds should appear instead of original seconds.
    Please Help!

    >
    To store call duration i have assigned a number field which is storing following type of data
    In above mentioned data decimals are seconds and left side is minutes.
    >
    Please provide info about the form in which you RECEIVE the data. Do you receive the data in MM.SS format like you say you are storing it?
    If not, why are you storing it this way?
    Unless you have some reason to STORE the data differently just store it the way you got it. That way you won't lose any precision and you can manipulate it any way you need to for display purposes.
    If you receive START_TIME and END_TIME then store both of those. Don't calculate and store duration; you will lose END_TIME and if you later need to calculate duration to a different precision you won't be able to.
    Where is the data being stored? Oracle?
    Write a simple function to convert a duration to minutes and seconds using the '>30' rule you have. Then if the rule changes you can write a new function or modify the existing one and the data itself doesn't have to change.

  • Convert number to date

    Hello.
    I'm new at this stuff and need a hand with a function.
    I have a Customer table that has a Date set as a number. 
    When I drag this field on to the report I get the following: 20,071,101.00
    Which makes complete sense since it is a number field.
    How do I convert this field to a date format?
    I tried the following:
    cDateTime ({CUS.DATESTART})
    Unfortunately, I'm doing something wrong as it is providing me with the following error:
    Error: Dates must be between year 1 and year 9999
    What am I doing wrong?
    Perhaps there is a much easier method then trying to create function...
    Thanks in advance for your assistance.
    Stephane

    Hello Raghavendra.
    Your solution has provided my answer.
    I will provide my final solution for others to view:
    Date(tonumber(left(totext({CUS.DATESTART},'##'),4)),tonumber(mid(totext({CUS.DATESTART},'##'),5,2)),tonumber(right(totext({CUS.DATESTART},'##'),2)))
    Notice how I substituted the actual date with the field(number).
    Here is reported field: 01/11/2007
    Note: my field value at this point was equal to CUS.DATESTART = 20,071,101.00
    Thank you very much for your quick assistance.
    Stephane

Maybe you are looking for