Description of common DB2 functions-Date and Time Functions (1)

Source: Internet
Author: User
Tags db2 functions

The following articles mainly describe the date and time functions of common DB2 functions. If you are a popular topic of Date and Time Functions of common DB2 functions. The following article is meaningful to you. The following is a detailed description of the relevant content.

Article category: Database keywords: db2, functions, date and time

Common DB2 functions: DATE Functions

Syntax: DATE (ARG)

The DATE function returns a DATE in a DATE, timestamp, DATE string, or timestamp string.

SQL code

Eg:

Select date ('1970-06-12 16.24.18.121212 ') FROM TEST

Eg:

Select date ('1970-06-12 16.24.18.121212 ') FROM TEST

Common DB2 functions: TIME Functions

Syntax: TIME (ARG)

The TIME function returns the TIME of a TIME, timestamp, or timestamp string parameter.

SQL code

Eg:

Select time ('2017-06-12 16.24.18.121212 ') FROM TEST

Eg:

Select time ('2017-06-12 16.24.18.121212 ') FROM TEST

Common DB2 functions: TIMESTAMP Functions

Syntax: TIMESTAMP (EXPRES1 [, EXPRES2])

The TIMESTAMP function returns the TIMESTAMP of one or two parameters.

SQL code

Eg:

Select timestamp ('2017-06-12 16.24.18.121212 ') FROM TEST

Eg:

Select timestamp ('2017-06-12 16.24.18.121212 ') FROM TEST

Note: if there is only one parameter, this parameter must be a timestamp or a timestamp string. If there are two parameters, the first parameter must be a date or date string, the second parameter must be a time or timestamp string.

DB2 common functions: YEAR Functions

Syntax: YEAR (ARG)

The YEAR function returns the YEAR of a date, timestamp, date string, and timestamp string.

SQL code

Eg:

Select year ('1970-06-12 ') FROM TEST

Eg:

Select year ('1970-06-12 ') FROM TEST

MONTH Function

Syntax: MONTH (ARG)

DB2 common functions: the MONTH function returns the MONTH portion of a date, timestamp, date string, and timestamp string.

SQL code

Eg:

Select month ('2014-06-12 ') FROM TEST

Eg:

Select month ('2014-06-12 ') FROM TEST

QUARTER Functions

Syntax: QUARTER (ARG)

The QUARTER function returns the QUARTER of a date, timestamp, date string, and timestamp string.

SQL code

Eg:

Select quarter (current date) FROM TEST

Eg:

Select quarter (current date) FROM TEST

WEEK Function

Syntax: WEEK (ARG)

The WEEK function returns the WEEK part of a date, timestamp, date string, and timestamp string.

SQL code

Eg:

Select week (current date) FROM TEST

Eg:

Select week (current date) FROM TEST

Common DB2 functions: DAY functions

Syntax: DAY (ARG)

The DAY function returns the DAY part of a date, timestamp, date string, and timestamp string.

SQL code

Eg:

Select day (current date) FROM TEST

Eg:

Select day (current date) FROM TEST

HOUR Function

Syntax: HOUR (ARG)

The HOUR function returns the HOUR part of a date, timestamp, date string, and timestamp string.


Related Article

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.