Results 1 to 4 of 4

Thread: Number to Text

  1. #1
    Join Date
    Jul 2008
    Posts
    2

    Unanswered: Number to Text

    I am new to db2 syntax.

    I have a date field that i have pulled the year out of by using
    year(table.field)
    and this works fine. Now what I need to do is turn this into a text field and remove all the commas and decimals that are within the field. I usually do it by using ToText({Table.NumField}, 0, ""). However, this does not seem to be a syntax that db2 likes. What would be the db2 way of accomplishing what i need?

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Those curly braces don't look like valid DB2 syntax. Check out scalar functions; I don't really understand what you are trying to achieve but there must be something that will help you.

    http://publib.boulder.ibm.com/infoce...n/c0000767.htm
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jul 2008
    Posts
    2
    The Frech brackets are part of the syntax crystal reports uses. no biggie on removie them for what I am trying to do now.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    If you use the YEAR() function, you get an integer. You can apply the CHAR() function to convert the integer to a string:
    Code:
    SELECT CHAR(YEAR(table.field))
    FROM   table
    What I don't understand is the part about "commas and decimals". Could you explain this a bit more?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •