Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My database table is returning year

Status
Not open for further replies.

DB2Problem

Programmer
Oct 17, 2002
53
US
My database table is returning years as

1999, 2000, 2001, 2002 from the year_description field. I want to assign a unique char datatype (year_code) to this.

For Example -

1, 1999
2, 2000
3, 2001

I can not modifying/add anything in the database. How can I do this in SQL or java
 
If year_description is a numeric field and will always be greater then 1998, you could use something like:

Code:
EXEC SQL 
   SELECT CHAR(year_description - 1998)
   INTO :year_code
...

If year_description is a character field, it is a little more difficult. And if I have misunderstood the problem entirely, please let me know and I'll take another crack at it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top