Results 1 to 8 of 8
  1. #1
    Join Date
    Dec 2009
    Posts
    15

    Unanswered: How to add timestamp column

    Hi,

    using DB V9.5

    How to add two timestamp column through sql query.

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    alter table table-name add column column-name timestamp;

    A reorg is optional, but recommended, especially if you plan on updating the column for existing rows.
    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
    Dec 2009
    Posts
    15
    Thanks for u'r response,

    not add columns in table .

    my question is How to sum both the column that have timestamp datatype

    ie.

    1. select (timestamp1_col) + (timestamp2_col) from test ;

    2. select sum (timestamp1_col + timestamp2_col) from test;

    while exceute this command ,getting the error the following error

    SQL0402N The data type of an operand of an arithmetic function or operation
    "+" is not numeric. SQLSTATE=42819

    SQL0402N The data type of an operand of an arithmetic function or operation "+ " is not numeric.

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    What result(data type and value) do you expect by adding timestamp columns?

    For example:
    TIMESTAMP('2010-04-27-09.13.56.234') + TIMESTAMP('2010-04-28-14.22.19.789') = ??????(what are your expected data type and value?)

  5. #5
    Join Date
    Dec 2009
    Posts
    15
    thanks again

    Expacting Integer datatype and value should in minute

  6. #6
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Expacting Integer datatype and value should in minute
    TIMESTAMP('2010-04-27-09.13.56.234') + TIMESTAMP('2010-04-28-14.22.19.789') = xxxx minutes?

  7. #7
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    saching,

    If you gave your answer to the following expression(hopefully with the way to calculate the answer),
    TIMESTAMP('2010-04-27-09.13.56.234') + TIMESTAMP('2010-04-28-14.22.19.789') = xxxx minutes?
    I will try to give you DB2 SQL expression(and/or UDF) to produce the answer.

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

    Exclamation Minus, only

    Quote Originally Posted by saching View Post
    Thanks for u'r response,

    not add columns in table .

    my question is How to sum both the column that have timestamp datatype

    ie.

    1. select (timestamp1_col) + (timestamp2_col) from test ;

    2. select sum (timestamp1_col + timestamp2_col) from test;

    while exceute this command ,getting the error the following error

    SQL0402N The data type of an operand of an arithmetic function or operation
    "+" is not numeric. SQLSTATE=42819

    SQL0402N The data type of an operand of an arithmetic function or operation "+ " is not numeric.
    You can use only one arithmetic operation between two timestamps: "-".


    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
  •