473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DB2 AS400 convert character to date format

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
2 32368
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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Loi Tan Vo | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be imported, I want to convert the date column to date type. For...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
11
by: jguilford | last post by:
I have created a SQL Stored Procedure that uses a Case statement to determine the Order By. For one of the Case statements I am trying to turn a Char field into Datetime in for the Order By,...
0
by: ggnanaraj | last post by:
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...
7
by: Nimmy | last post by:
Hi, I have a file which has different dates, I want to scanf them as CHAR and convert them to DATE format, how can I do this? Thanks
0
by: D.Saravanan | last post by:
I am using asp.net to connect to the DB2/400 database on the AS400. When I connect through windows forms or console application, the connection works fine. But when I connect through asp.net I get...
1
by: izziy | last post by:
Our legacy DB has a bad column which stores a date value as char(8), it has a format like 'MMDDYYYY'. I am creating a report to report this particular date and also use this date to specify a...
0
by: oncorhynchus | last post by:
All: CAVEAT: I'm not really an AS400 jockey, I just play one on TV. Keeping that in mind...... I'm using a legacy AS400 application where all dates are stored as Integers, e.g. 05/01/2007 =...
0
by: tbrmc | last post by:
Hi frnds, Could anybody tell me how to convert date in character type field into particular date format
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.