By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,226 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,226 IT Pros & Developers. It's quick & easy.

DB2 AS400 convert character to date format

P: n/a
In AS/400, have a table that has a character field defined. This has to
be converted to date format of YYYY-MM-DD.

The sample character data is as follows: 02/05/2005.

In UDB, you can do a bind of DB2 utility packages to use ISO, USA or
some other format. What is to be done in AS/400 to achieve the same?

TIA.

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ggnanaraj wrote:
In AS/400, have a table that has a character field defined. This has to
be converted to date format of YYYY-MM-DD.

The sample character data is as follows: 02/05/2005.

In UDB, you can do a bind of DB2 utility packages to use ISO, USA or
some other format. What is to be done in AS/400 to achieve the same?

TIA.


With DB2 UDB for iSeries you could try this:

select char(date(my_column), iso)

For example using STRSQL:

select char(date('02/05/2005'),iso) from qsys2/qsqptabl

....+....1....+
CHAR conversion
2005-02-05
******** End of data ********

--
Karl Hanson
Nov 12 '05 #2

P: n/a


Karl Hanson wrote:
ggnanaraj wrote:
In AS/400, have a table that has a character field defined. This has to
be converted to date format of YYYY-MM-DD.

The sample character data is as follows: 02/05/2005.

In UDB, you can do a bind of DB2 utility packages to use ISO, USA or
some other format. What is to be done in AS/400 to achieve the same?

TIA.


With DB2 UDB for iSeries you could try this:

select char(date(my_column), iso)

For example using STRSQL:

select char(date('02/05/2005'),iso) from qsys2/qsqptabl

....+....1....+
CHAR conversion
2005-02-05
******** End of data ********

--
Karl Hanson


Thank you very much, it is working...
[db2inst1@dnetncs db2inst1]$ db2 "select arcdt from JODA.TRNAR# fetch
first 1 rows only"

ARCDT
----------
03/05/2005

1 record(s) selected.

[db2inst1@dnetncs db2inst1]$ db2 "describe select * from JODA.TRNAR#" |
grep -i arcdt
452 CHARACTER 10 ARCDT
6
[db2inst1@dnetncs db2inst1]$

[db2inst1@netncs db2inst1]$ db2 "select char(date(ardt), ISO) from
JOD.TRNA# fetch first 1 rows only"

00001
----------
2005-03-05

1 record(s) selected.

[db2inst1@netncs db2inst1]$

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.