Solved

SQL format of number

Posted on 2011-03-09
5
953 Views
Last Modified: 2012-05-11
I have a field Fiscal Year that returns the year as 2,009.  How do I in my SQL remove the , from the 2,009 value?
0
Comment
Question by:garyjgs
5 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 35084939
try

select substr(year, 1,1) || substr(year,3,3)
from your_tbale
0
 
LVL 18

Accepted Solution

by:
daveslash earned 500 total points
ID: 35085087

It's probably easiest to just convert it to a varchar.

e.g.

select varchar(theValue) as theYear
  from deleteme

THEYEAR
2009

Open in new window

0
 
LVL 45

Expert Comment

by:Kdo
ID: 35085470

Hi Gary,

If the value '2,000' is stored in the table, momi's suggestion works fine.

I prefer the replace() function though.


  SELECT replace (TheYear, ',', '') FROM mytable;


Good Luck,
Kent
0
 

Author Closing Comment

by:garyjgs
ID: 35086079
Worked as suggested.  Thanks.
0
 

Author Comment

by:garyjgs
ID: 35086084
Worked as suggested. Thanks.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question