Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2012
    Posts
    2

    Unanswered: oracle query not working in db2

    Dear friend
    Need help

    below query fine in oracle
    select add_months ( '01-sep-2012' ,12)- 1 from dual;

    but in db2 it is not working anybody suggest what change I required

    REgards

    pravin

  2. #2
    Join Date
    Jun 2007
    Location
    germany
    Posts
    155
    oracle query not working in db2
    maybe it needs a permit.
    Dick Brenholtz, Ami in Deutschland

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    ---
    "It does not work" is not a valid problem statement.

  4. #4
    Join Date
    Nov 2003
    Location
    California,USA
    Posts
    72
    try this in DB2 9.7 ....
    select ADD_MONTHS('2008-2-29',4) from sysibm.sysdummy1;

  5. #5
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Quote Originally Posted by pravinsali12 View Post
    below query fine in oracle
    select add_months ( '01-sep-2012' ,12)- 1 from dual;

    but in db2 it is not working
    That's because it's not standard SQL.
    Unfortunately, there is not (yet) a standard for nor the "add months" function, nor the "system table with one row".
    For DB2 on z/OS, the following would be the typical equivalent:
    Code:
    SELECT date('01.09.2012') + 12 months - 1 day
    FROM sysibm.sysdummy1
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

Posting Permissions

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