DB2 Date function to read __ function in detail

Source: Internet
Author: User
Tags db2 db2 date month name

Date Function

Syntax: DATE (ARG)

The DATE function returns the dates in a date, time stamp, date string, and timestamp string. SQL code eg: SELECT DATE(' 2005-06-12 16.24.18.121212 ') from TEST

Eg:   
SELECT DATE (' 2005-06-12 16.24.18.121212 ') from TEST  



Time function

Syntax: Time (ARG)

Time function returns a time, time stamp, or a time, timestamp string parameter. SQL code eg: SELECT time (' 2005-06-12 16.24.18.121212 ') from TEST

Eg:   
SELECT time (' 2005-06-12 16.24.18.121212 ') from TEST  



Timestamp function

Syntax: TIMESTAMP (Expres1[,expres2])

The timestamp function returns a timestamp in one or two arguments. SQL code eg: SELECT TIMESTAMP(' 2005-06-12 16.24.18.121212 ') from TEST

Eg:   
SELECT TIMESTAMP (' 2005-06-12 16.24.18.121212 ') from TEST  


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


Year function

Grammar: Year (ARG)

The year function returns a date, time stamp, date string, and time stamp string. SQL code eg: SELECT year (' 2005-06-12 ') from TEST

Eg:   
SELECT year (' 2005-06-12 ') from TEST  



Month function

Syntax: MONTH (ARG)

The month function returns the month portion of a date, time stamp, date string, and timestamp string. SQL code eg: SELECT MONTH (' 2005-06-12 ') from TEST

Eg:   
SELECT MONTH (' 2005-06-12 ') from TEST  



Quarter function

Syntax: Quarter (ARG)

The quarter function returns the quarterly portion of a date, time stamp, 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 portion of a date, time stamp, date string, and timestamp string. SQL code eg: SELECT WEEK ( current DATE) from TEST

Eg:   
SELECT WEEK (current DATE) from TEST  



Day function

Syntax: Day (ARG)

The day function returns a date, time stamp, date string, and the date portion of the 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 portion of a date, time stamp, date string, and timestamp string. SQL code eg: SELECT HOURfrom TEST

Eg:   
SELECT HOUR (current time) from TEST  



minute function

Syntax: MINUTE (ARG)

The minute function returns the minute portion of a date, time stamp, date string, and timestamp string. SQL code eg: SELECT MINUTEfrom TEST

Eg:   
SELECT MINUTE (current time) from TEST  



Second function

Syntax: SECOND (ARG)

The second function returns the second part of a date, time stamp, date string, and timestamp string. SQL code eg: SELECT SECONDfrom TEST

Eg:   
SELECT SECOND (current time) from TEST  



Days function

Syntax: Days (ARG)

The days function returns an integer representation of the date, time stamp, date string, and time stamp string, from 0001-01-01 onwards. SQL code eg: SELECT days from TEST

Eg:   
SELECT days from TEST  



dayofyear Function

Syntax: DayOfYear (ARG)

The DayOfYear function returns the day value of a date, time stamp, date string, and timestamp string during the year. SQL code eg: SELECT dayofyear ( current DATE) from TEST

Eg:   
SELECT dayofyear (current DATE) from TEST  



DayOfWeek function

Syntax: DayOfWeek (ARG)

The DayOfWeek function returns the day value of a date, time stamp, date string, and timestamp string within the week (starting from Sunday 1 to 7). SQL code eg: SELECT DayOfWeek ( current DATE) from TEST

Eg:   
SELECT dayofweek (current DATE) from TEST  



Dayofweek_iso function

Syntax: Dayofweek_iso (ARG)

The Dayofweek_iso function returns the day value of a date, time stamp, date string, and timestamp string within the week (starting from Monday 1 to 7). SQL code eg: SELECT dayofweek_iso ( current DATE) from TEST

Eg:   
SELECT dayofweek_iso (current DATE) from TEST  



dayname function

Syntax: Dayname (ARG)

The Dayname function returns a date, time stamp, date string, and time stamp string that is the day of the week. SQL code eg: SELECT dayname ( current DATE) from TEST

Eg:   
SELECT dayname (current DATE) from TEST  



MonthName Function

Syntax: MonthName (ARG)

The MonthName function returns the month name of a date, time stamp, date string, and timestamp string. SQL code eg: SELECT monthname ( current DATE) from TEST

Eg:   
SELECT monthname (current DATE) from TEST  



midnight_seconds function

Syntax: Midnight_seconds (ARG)

The Midnight_seconds function returns the number of seconds between midnight and the time value specified by the parameter, expressed as an integer value between 0 and 86400. SQL code eg: SELECT midnight_seconds from TEST

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.