Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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).
    Last edited by Marcus_A; 07-29-10 at 03:01.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •