If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Number to Text

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-18-08, 14:41
giggles7840 giggles7840 is offline
Registered User
 
Join Date: Jul 2008
Posts: 2
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?
Reply With Quote
  #2 (permalink)  
Old 07-18-08, 15:00
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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
Reply With Quote
  #3 (permalink)  
Old 07-18-08, 15:04
giggles7840 giggles7840 is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 07-19-08, 04:14
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On