• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 985
  • Last Modified:

SQL format of number

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
garyjgs
Asked:
garyjgs
1 Solution
 
momi_sabagCommented:
try

select substr(year, 1,1) || substr(year,3,3)
from your_tbale
0
 
Dave FordSoftware Developer / Database AdministratorCommented:

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
 
Kent OlsenData Warehouse Architect / DBACommented:

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
 
garyjgsAuthor Commented:
Worked as suggested.  Thanks.
0
 
garyjgsAuthor Commented:
Worked as suggested. Thanks.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Tackle projects and never again get stuck behind a technical roadblock.
Join Now