String to number and Number to String Problem!

Hi All,
In my report i ahve to display the Date.
From DB i am getting 4 digit string( 2008). Using that i have to display as 08 - 09
In that i used RIGHT function. it is diplayed as 08 - 9.
when i take 2 character from right '08' is coming. Then i converted to number and added 1 to the year
But it become 9 instead of 09.
How to solve it.
Thanks in advance.
Saravanakumar.

Hi,
Shweta's answer is valid when you retrieve a date field from the database, as you have specified that you are getting a four digit string, you should use this formula.
if length(totext(tonumber(right('2008',2))+1)) = 4
then
right('2008',2)'-0'left(totext(tonumber(right('2008',2))+1),1)
else
right('2008',2)'-'left(totext(tonumber(right('2008',2))+1),2)
hope this helps!!!
Thanks
-Azhar
Edited by: Abdul Rehman Mushtaque on Mar 29, 2009 10:29 AM

Similar Messages

  • What is the difference between string != null and null !=string ?

    Hi,
    what is the difference between string != null and null != string ?
    which is the best option ?
    Thanks
    user8729783

    Like you've presented it, nothing.  There is no difference and neither is the "better option".

  • Difference between datatype NUMBER and NUMBER(38)

    Difference between datatype NUMBER and NUMBER(38)

    From
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330
    NUMBER Datatype
    The NUMBER datatype stores zero as well as positive and negative fixed numbers with absolute values from 1.0 x 10-130 to (but not including) 1.0 x 10126. If you specify an arithmetic expression whose value has an absolute value greater than or equal to 1.0 x 10126, then Oracle returns an error. Each NUMBER value requires from 1 to 22 bytes.
    Specify a fixed-point number using the following form:
    NUMBER(p,s)
    where:
    p is the precision, or the total number of significant decimal digits, where the most significant digit is the left-most nonzero digit, and the least significant digit is the right-most known digit. Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point.
    s is the scale, or the number of digits from the decimal point to the least significant digit. The scale can range from -84 to 127.
    Positive scale is the number of significant digits to the right of the decimal point to and including the least significant digit.
    Negative scale is the number of significant digits to the left of the decimal point, to but not including the least significant digit. For negative scale the least significant digit is on the left side of the decimal point, because the actual data is rounded to the specified number of places to the left of the decimal point. For example, a specification of (10,-2) means to round to hundreds.
    Scale can be greater than precision, most commonly when e notation is used. When scale is greater than precision, the precision specifies the maximum number of significant digits to the right of the decimal point. For example, a column defined as NUMBER(4,5) requires a zero for the first digit after the decimal point and rounds all values past the fifth digit after the decimal point.
    It is good practice to specify the scale and precision of a fixed-point number column for extra integrity checking on input. Specifying scale and precision does not force all values to a fixed length. If a value exceeds the precision, then Oracle returns an error. If a value exceeds the scale, then Oracle rounds it.
    Specify an integer using the following form:
    NUMBER(p)
    This represents a fixed-point number with precision p and scale 0 and is equivalent to NUMBER(p,0).
    Specify a floating-point number using the following form:
    NUMBER
    The absence of precision and scale designators specifies the maximum range and precision for an Oracle number.
    And
    2
    NUMBER[(precision [, scale]])
    Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127
    Sybrand Bakker
    Senior Oracle DBA

  • Convert time to number and number to time

    I'm using SAP 4.0b
    I'm looking for function that converts time to number and number to time.
    Any suggestion?

    Hi,
    Can you give an example of what number you want to give to get what time and vice-versa?
    There can be a direct conversion between an integer and a time variable in ABAP.
    For example -
    data: number type i,
          time type syuzeit.
    number = 3600.
    move number to time.
    write time.
    The time will be output as "01:00:00". That is because 3600 seconds make up one hour.
    Regards,
    Anand Mandalika.

  • Retreiving number and characters from string

    Hello fellow developers,
    Lets say i have the following string ER686 and want to split the string into a number and characterpart resulting in a String "ER" and an int "686". What is the best approach to accomplish this?
    Thank you for any help offered.

    The format is that there's a sequence of strings 2 or
    3 and a squence of numbers 3 or 4You might use a Pattern matcher, using a regular expression like the following :"(\\D{2,3})(\\d{3,4})"This expressions represents "two or three non-digit characters followed by 3 or 4 digits". The parenthesis are here to allow getting the two elements (groups) separately.
    Use the find() method of the matcher, then retrieve the two groups with group(1) and group(2).
    Eventually, parse the latter if required.

  • String to Int and Int to String

    How can I convert a string to Int & and an Int to String ?
    Say I've
    String abc="234"
    and I want the "int" value of "abc", how do I do it ?
    Pl. help.

    String.valueOf(int) takes an int and returns a string.
    Integer.parseInt(str) takes a string, returns an int.
    For all the others long, double, hex etc. RTFM :)

  • Invalid Serial number and RAM memory upgrade problem

    1. Please, I am trying to reinstall Snow Leopard, at the end is coming
    "Invalid serial number entered Setup requires a valid serial number. The serial number has the format XSVR-106-x-xxx-xxx-xxx-xxx-xxx-xxx-x!
    but my serial number is:
    C07XXXXXXXXX!
    What is wrong?
    2. When I try to install 1 DDR Kingston 8GB PC3 10600 CL9 204-PIN SODIMM is coming a clicking sound, What is the problem?
    Thanks.

    All OS X Server 10.6 purchases include a product serial number key, and this serial number key is a required part of the OS X Server installation.   This is a product activation key, and as shown in the display this key begins with XSVR-106 for OS X Server 10.6.  This key was included with the paperwork from the original purchase on a couple of stickers on a card, if this system was acquired with OS X Server 10.6.  If this OS X Server 10.6 media was acquired from elsewhere, then look for a sticker with the media and packaging.  Otherwise, please contact the vendor and ask for the serial number for the media you've acquired.  If you've purchased this Mac Mini with OS X Server 10.6 from Apple directly and no longer have the key, then you'll want to contact Apple Support for assistance.
    As for your second (memory) question, presumably the memory is not compatible with your particular Mac Mini, or there's a problem with the memory itself.  There are usually tech specs available listing the particular requirements for the memory for a particular Mac Mini system.  If you purchased this memory from Kingston specifically for this particular system, contact the Kingston support folks and ask for assistance.
    If you post the specific model of Mac Mini, somebody here can probably locate the memory requirements.

  • Load String into CharArray and then Print String in Reverse?

    Hey, what would the code be to:
    1. Ask user for name. (scanner)
    2. Load his name into a CharArray.
    3. Then print out his name backwards.
    thanks a lot!

    dforevergold has a head on his neck. So, I don't understand people saying about assignments etc... If he needs help and we can help then we must help.
    Here's the code (but don't forget about comments!):
    import java.util.Scanner;
    public class Just {
         public static void main(String[] args) {
              // a scanner to get user's input
              Scanner scan = new Scanner(System.in);
              // Scanner.nextLine() returns the entered line
              String name = scan.nextLine();
              // toCharArray() converts a 'String' object to a 'char[]' object
              char[] ch = name.toCharArray();
              // next FOR-loop goes from the last element in the array to the first one and prints them onscreen
              for (int i = ch.length - 1; i >= 0; --i) System.out.print(ch);
    I hope it helps you!
    Yours Sincerely,
    Nikaustr

  • Searching for End of line char in a string...and EOF in string.

    Suppose I open up a file and read it right into a StringBuffer. Once I have that, how can i searching using StringBuffer.indexOf(whathereforEOL) for a end of line, i suspect its perhaps some sort of escape character but I am not sure what it is in java or if java even uses escape characters.
    I really need
    .indexOf(EOL); somehow, and perhaps .indexOf(EOF); //if end of file character is retrieved using a StringBuffer that was completed using a BufferedReader based on a input stream reader.
    Thanks for any info here,
    Shane

    End-of-line is denoted in a platform-specific way.
    Some variations depending on the platform:
    "\r"
    "\n"
    "\r\n"
    A sidenote. I remember some platforms maintaining the notion of "sequential" (and h�las, of "index-sequential") files. Unix and Windows store the files as byte streams without OS-imposed internal structure, that is the point of view of C as well.
    But if you use BufferedReader.readLine() you get the lines one after the other.
    EOF is handled by the OS. You will not read an "EOF" marker.
    -1 rather denotes in the API that end-of-file is reached.
    There is no way to actually read -1 as a byte or a character from a file or other data source.

  • Planned order number and Plnkn

    Dear All,
    I need the table link between planned order number and Number of the task list node(PLNKN).
    Thank you in advance
    Regards
    Sailendra.M
    Edited by: nivedita yadav on Jun 25, 2010 2:35 PM

    Dear Nivedita,
    Check with this functional Module in SE37
    BAPI_PLANNEDORDER_GET_DETAIL
    In my understanding I dont think nwe can get this data from table.
    Regards
    S Mangalraj

  • How to Plot number and string in one row (data logger counter) ?

    hi all i made data log quantity using Digital Counter via modbus to monitoring quantity and reject that has and Name Operator, Machine and Part Number.
    i have problem about plot the number & string in one row, as shown on the picture below :
    how to move that string on one row ? i attach my vi.
    Thanks~
    Attachments:
    MODBUS LIB Counter.vi ‏39 KB

    Duplicate and answered - http://forums.ni.com/t5/LabVIEW/How-to-Plot-number-and-string-in-one-row-data-logger-counter-via/m-p...

  • How to convert a String Variable to a Number and retain decimal place

    Hello!
    Here is my problem!
    I am receiving information from a source that I cannot control.  It is sending me Numbers in to form of strings.
    Ex: 12,200.49
    I have tried usingval() but only get " 12 " because it stops when it see a comma or period.
    I have also tried using Replace() to remove the comma and period, but then my number grows, because the last two digits are now part of the number and no longer behind a decimal point.
    Here is some example code
    <cfset Price = "12,200.49">
    <cfoutput>
    #val(Price)#
    <cfset Price = '#Replace(Price,",","","ALL")#'>
    <BR />
    #val(Price)#
    <cfset Price = '#Replace(Price,".","","ALL")#'>
    <BR />
    #val(Price)#
    <cfset Price = #NumberFormat(Price, "_____.__")#>
    <BR />
    FINISHED WITH #Price#
    </cfoutput>
    The output of the above code is this:
    12
    12200
    1220049
    FINISHED WITH 1220049.00
    So, you can see that 12,200.49 is now 1,220,049.00 because the two digits where added.
    What I would like to finish with is a String "12,200.49" that is now a Number like this $12,200.49
    Please help!!!

    HI
    try this
    <cfoutput>
        <cfset t="12,200.49">
        <cfset Price = Replace(t,",","","ALL")>
    #DollarFormat(Price )#
    </cfoutput>

  • Not able to convert string attribute to number and date please help me out

    not able to convert string attribute to number and date attribute. While using string to date conversion it shows result as failure.As I am reading from a text file. please help me out

    Hi,
    You need to provide an example value that's failing and the date formats in the reference data you're using. It's more than likely you don't have the correct format in your ref data.
    regards,
    Nick

  • Got String= "100 600" and want to get out (length of first number not const

    Ive got String= "100 600" and want to get out
    the value 600 into int.
    Length of first number is not const : it can be 100 or 3000
    How can how do it ?
    10x for the help

    It would depend on the format of your string. If you can gurantee that the format will always be "number number" then you can use the StringTokenizer to split the two numbers and take the second one. The code would look similar to this:
    String s = "100 600";
    StringTokenizer st = new StringTokenizer(s, " ");
    //--- This "scrolls" past the first number.
    st.nextToken();
    String num = st.nextToken();
    The variable num will always have the second number.
    Hope this helps.

  • Separating character and number within the string

    I want to separate the character and the number within one string.
    For example,
    12345ABCD (the numbers and character may differ in lengths)
    I want to separate into two different string of 12435 and ABCD.
    Your help would be greatly appreciated.
    Thanks!

    here is an example:
    sample_separator.sql
    declare
      i        number := 0;
      j        number := 0;
      x        number := 0;
      vBasis   Varchar2(40) := '12345ABCD';
      vString1 Varchar2(40);
      vString2 Varchar2(40);
    begin
      for x in 1 .. length(vBasis) loop
        for i in 0 .. 9 loop
          if substr(vBasis,x,1) = to_char(i) then     
            vString1 := vString1 || substr(vBasis,x,1);
          end if;
        end loop;
        for j in 65 .. 90 loop
          if substr(vBasis,x,1) = chr(j) then
            vString2 := vString2 || substr(vBasis,x,1);
          end if;
        end loop;   
      end loop;
      dbms_output.put_line('vString1: '||vString1);
      dbms_output.put_line('vString2: '||vString2);
    end;
    /when run:
    SQL> @r:\sample_separator.sql;
    vString1: 12345
    vString2: ABCD
    PL/SQL procedure successfully completed.
    SQL> hope this helps.

Maybe you are looking for

  • Standard report for subcontracting cost

    Hi, Is there any std report exists for total sub-contracting cost dorn over a period of time in PP? Pls advise.

  • Can we set tax amount directly instead of tax code?

    Hi, Is there a way to set the TaxAmount value in an A/R Invoice document line object instead of tax code? Thanks and Regards, Sheetal

  • Run an AIR app headless?

    Hi there, So my problem is this: We created an awesome reporting tool built using Flex. Currently the user can output a PDF of their report through the app. We used AlivePDF to accomplish this. Now product management has upped the ante wanting to gen

  • Using iPad to fill forms

    I understand that FormsCentral forms can be filled out and submitted using an iPad only through Adobe Reader. Is there a maximum size/width the form can be to best fit on the iPad or does it scale regardless?

  • Timeline in iMovie6

    the timeline in my iMovie has dimmed and nothing seems to bring it back to full color. Any suggestions? Nekosan