Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Date format in export files

473 views
Skip to first unread message

Will Honea

unread,
Oct 8, 2010, 12:29:02 AM10/8/10
to
Express-C 9.7.2 LUW. I need to generate CSV text files containing dates in
a specific format. I know there is (or used to be as it's in my existing
scripts) a way to force something besides the yyyymmdd default (I need
yyyy/mm/dd) but the docs show only a modifiedby spec for timestampformat for
the EXPORT command. The docs do show modifier specs for dateformat and
timeformat for the IMPORT command as well but only the timestampformat for
EXPORT. What simple thing am I missing here (maybe codepage) to get this
done?

--
Will Honea

Mark A

unread,
Oct 8, 2010, 2:27:02 PM10/8/10
to
"Will Honea" <who...@yahoo.com> wrote in message
news:k6xro.114$4e4...@newsfe11.iad...

You can always substring the date:

db2 "export to employee.del of del select empno,
substr(birthdate,1,4)||'/'||substr(birthdate,6,2)||'/'||substr(birthdate,9,2)
from emp"

"000010","1963/08/24"
"000020","1978/02/02"
"000030","1971/05/11"
"000050","1955/09/15"
"000060","1975/07/07"


Hardy

unread,
Oct 8, 2010, 2:36:53 PM10/8/10
to

"yyyy/mm/dd" is not of any international date format. the nearly is
ISO or JIS standard which is "yyyy-mm-dd". in your format, you are
on your risk for the import side and you cannot use sth. like modified
by dateiso.


values cast(replace(char(current date,ISO),'-','/') as char(10))

1
----------
2010/10/08

1 record(s) selected.


Ian

unread,
Oct 8, 2010, 1:18:41 AM10/8/10
to
On Oct 7, 11:29 pm, Will Honea <who...@yahoo.com> wrote:

You'll have to use TO_CHAR to reformat your date in the select
statement,
not via an EXPORT option:

select TO_CHAR(CURRENT_DATE, 'YYYY/MM/DD') from sysibm.sysdummy1

1
----------------...
2010/10/07 ...


Frederik Engelen

unread,
Oct 8, 2010, 3:50:16 AM10/8/10
to

Hello Will,

Would this work for you? Having a dateformat modifier would be cleaner
indeed.

select to_char(timestamp_iso(date_column),'YYYY/MM/DD') from table

--
Frederik Engelen

Will Honea

unread,
Oct 8, 2010, 3:42:16 PM10/8/10
to
Ian wrote:

Thanks, all. This was my brute force approach and seems to be the consensus
method. I just hated to cobble up a simple "select *" with the expanded form
on a 65 column table export - laziness loses again ;-)

--
Will Honea

0 new messages