Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2007
    Posts
    27

    Unanswered: Get Current TimeStamp

    Hi Guys!,

    How to get the current timestamp in the whole Database regardless of table.

    Thanks,
    MabelJovan

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    values (current timestamp)

    Andy

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    DB2 z/OS does not yet understand the VALUES table constructor. Then you would do this (works also on LUW):
    Code:
    SELECT CURRENT TIMESTAMP
    FROM   sysibm.sysdummy1
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,
    by the way... will IBM ever create DB2 ISO standard compatible way of accessing "current timestamp" variable?

    This is important if you write a program to multiple databases (DB2, Oracle, MySQL etc). To have only one SQL code instead of multiple SQL code and multiple program versions.

    More info about current timestamp and IBM implementation:
    http://troels.arvin.dk/db/rdbms/#dat...time-timestamp

    Thanks,
    Grofaty

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    What exactly do you mean with "ISO standard compatible way"?

    You can query the current timestamp in DB2 using:
    Code:
    CURRENT TIMESTAMP
    or
    Code:
    CURRENT_TIMESTAMP
    The latter is what the SQL standard defines, too.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,
    sorry I attached the wrong link... The message is little bit down in document. So right link is:
    http://troels.arvin.dk/db/rdbms/#fun...LOCALTIMESTAMP

    At Standard section:
    Code:
    If the DBMS supports the non-core time zone features (feature ID F411),
     then it must also provide the functions CURRENT_TIMESTAMP and
     CURRENT_TIMESTAMP(precision) which return a value of type TIMESTAMP
    WITH TIME ZONE. If it doesn't support time zones, then the DBMS
     must not provide a CURRENT_TIMESTAMP function.
    So DB2 brakes this rule: "then the DBMS must not provide a CURRENT_TIMESTAMP function."

    At DB2 section:
    Code:
    the availability of CURRENT_TIMESTAMP could be said
    to be against the standard—at least confusing.
    Regards,
    Grofaty
    Last edited by grofaty; 09-06-07 at 06:32.

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Could you please provide me with a reference (number of the subclause) where this is written in the standard? I'm just curious because - usually - the standard does not mandate that a conforming implementation does not provide some functionality if it does not support a certain feature.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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