DB2 time operation

Source: Internet
Author: User

The following is compiled from the DB2 Foundation: use of dates and times

1. Use SQL to get the current timestamp of the database server

    1. SELECT current date from sysibm.sysdummy1
    2. SELECT current time from sysibm.sysdummy1
    3. SELECT current timestamp from sysibm.sysdummy1

description : The SYSIBM.SYSDUMMY1 table is a special in-memory table that can be used to display the value of the DB2 register as shown above. Here, the current date, the current time, and current timestamp are the names of the special registers of the DB2.

In addition to using SQL, you can use the keyword values to evaluate a register or an expression. For example, on the DB2 command line PROCESSOR,CLP, enter the following command:

    1. VALUES Current date
    2. VALUES Current time
    3. VALUES Current timestamp

description : Another way to use the register name of current date, current time, current timestamp, etc. is current_date, Current_time, Current_ Timestamp

2. Use current timezone register to adjust GMT or cut time zone

    1. Current time-current timezone
    2. Current timestamp-current timezone

Note : The current timezone is also a special register of the DB2, as is the register with the present time, and its value is the correction value of the currently timezone.

3. Use the function to extract the year, month, day, time, minute, second and microsecond

  1. Year (current timestamp)
  2. MONTH (current timestamp)
  3. Day (current timestamp)
  4. HOUR (current timestamp)
  5. MINUTE (current timestamp)
  6. SECOND (current timestamp)
  7. Microsecond (current timestamp)

Extract date and time from timestamp

    1. DATE (current timestamp)
    2. Time (current timestamp)

4. Use English to perform date and time calculations

    1. Current date + 1 year
    2. Current date + 3 years + 2 MONTHS +
    3. Current time + 5 HOURS-3 MINUTES + SECONDS

Not finished ...

DB2 time operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.