dbTalk Databases Forums  

Date format in export files

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Date format in export files in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Will Honea
 
Posts: n/a

Default Date format in export files - 10-07-2010 , 11:29 PM






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

Reply With Quote
  #2  
Old   
Ian
 
Posts: n/a

Default Re: Date format in export files - 10-08-2010 , 12:18 AM






On Oct 7, 11:29*pm, Will Honea <who... (AT) yahoo (DOT) com> wrote:
Quote:
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?
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 ...

Reply With Quote
  #3  
Old   
Frederik Engelen
 
Posts: n/a

Default Re: Date format in export files - 10-08-2010 , 02:50 AM



On Oct 8, 6:29*am, Will Honea <who... (AT) yahoo (DOT) com> wrote:
Quote:
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
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

Reply With Quote
  #4  
Old   
Mark A
 
Posts: n/a

Default Re: Date format in export files - 10-08-2010 , 01:27 PM



"Will Honea" <whonea (AT) yahoo (DOT) com> wrote

Quote:
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
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"

Reply With Quote
  #5  
Old   
Hardy
 
Posts: n/a

Default Re: Date format in export files - 10-08-2010 , 01:36 PM



On Oct 7, 11:29*pm, Will Honea <who... (AT) yahoo (DOT) com> wrote:
Quote:
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
"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.

Reply With Quote
  #6  
Old   
Will Honea
 
Posts: n/a

Default Re: Date format in export files - 10-08-2010 , 02:42 PM



Ian wrote:

Quote:
On Oct 7, 11:29 pm, Will Honea <who... (AT) yahoo (DOT) com> wrote:
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?

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 ...
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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.