If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Date format issue in DB2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-29-10, 00:13
ramendra ramendra is offline
Registered User
 
Join Date: Jul 2010
Posts: 1
Date format issue in DB2

We have migrated oracle DB to DB2 9.5.We are facing issue in date format of DB2(YYYY-MM-DD), but in oracle DB date it is stored in dd/mm/yyyyy.And our java application logic is based on oracle date format.so in DB2 our application is not working.
is there any way to change DB2 date format similar to Oracle from DB2 side?

Ramendra
Reply With Quote
  #2 (permalink)  
Old 07-29-10, 01:57
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
You are wrong about the way Oracle stores dates, and are confusing how the date is stored and how it is presented to you. In DB2 you can specify the way it is presented to you with the CHAR function.

db2 select birthdate, char(birthdate, ISO), char(birthdate, usa) from db2inst1.employee

BIRTHDATE 2 3
---------- ---------- ----------
08/24/1963 1963-08-24 08/24/1963
02/02/1978 1978-02-02 02/02/1978
05/11/1971 1971-05-11 05/11/1971
09/15/1955 1955-09-15 09/15/1955
07/07/1975 1975-07-07 07/07/1975
05/26/2003 2003-05-26 05/26/2003
05/15/1971 1971-05-15 05/15/1971
12/18/1980 1980-12-18 12/18/1980
11/05/1959 1959-11-05 11/05/1959


In the first column it comes back in the command line processor as USA format because my DB2 Type 2 Windows client was installed with US territory code. Using the Type 4 universal client with java may have returned the ISO format, but you can probably specify which is the default to use with some Db2 connection parm or other DB2 setting once you connect (if you don't want to use the CHAR function).
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 07-29-10 at 02:01.
Reply With Quote
  #3 (permalink)  
Old 07-29-10, 10:14
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Wink

DB2 is smart enough to understand different type of DATEs:

Code:
select date('07/29/2010')
from sysibm.sysdummy1
Result: 2010-07-29

Lenny
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On