473,378 Members | 1,146 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,378 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 32356
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.