DB2 Time Function Daquan

Source: Internet
Author: User
Tags time and date

DB2 time function is one of our most common functions, the following is to introduce you some DB2 time functions, for your reference, I hope you can have more understanding of the DB2 time function.

1 --get the current date:2  3 Select  CurrentDate fromsysibm.sysdummy1; 4 Values  Currentdate; 5  6 --Get Current date7 Select  CurrentTime fromsysibm.sysdummy1; 8 Values  CurrentTime ; 9 --gets the current time stampTen Select  Current timestamp  fromsysibm.sysdummy1;  One Values  Current timestamp;  A   - --to adjust the current time or current timestamp to gmt/cut, subtract the current time or time stamp from the current timezone register: -   the Values  CurrentTime- Currenttimezone;  - Values  Current timestamp - Currenttimezone;  -   - --get Current year +   - Values  Year( Current timestamp);  +   A --Get Current Month at Values Month( Current timestamp);  -   - --Get current day - Values  Day( Current timestamp);  -   - --Get current Time in ValuesHour Current timestamp);  -   to --Get minutes + ValuesMinute Current timestamp);  -   the --Get seconds * ValuesSecond Current timestamp);  $  Panax Notoginseng --get milliseconds - ValuesMicrosecond ( Current timestamp);  the   + --extract date and time separately from time stamp A   the ValuesDate Current timestamp);  + ValuesVarchar_format ( Current TIMESTAMP,'YYYY-MM-DD');  - Values Char( Currentdate);  $ ValuesTime Current timestamp);  $   - --calculation of execution date and time -   the Values  CurrentDate+1  Year;  - Values  CurrentDate+3Years+2Months+ theDays ; Wuyi Values  CurrentTime+5Hours-3Minutes+Tenseconds;  the   - --calculate the number of days between two dates Wu   - ValuesDays CurrentDate-Days (Date ('2010-02-20'));  About   $ --time and date changed to string -   - Values Char( Currentdate);  - Values Char( CurrentTime );  A   + --to convert a string to a date or time value the   - Values timestamp('2010-03-09-22.43.00.000000');  $ Values timestamp('2010-03-09 22:44:36');  the ValuesDate'2010-03-09');  the ValuesDate'03/09/2010');  the ValuesTime'22:45:27');  the ValuesTime'22.45.27');  -   in --calculate the difference between two time stamps: the   the --the number of seconds is divided into units About ValuesTimestampdiff (1,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  the --units of seconds the ValuesTimestampdiff (2,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  the --divided into units + ValuesTimestampdiff (4,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  - --hours for units the ValuesTimestampdiff (8,Char( Current timestamp - timestamp('2010-01-01-00.00.00'))); Bayi --Days for units the ValuesTimestampdiff ( -,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  the --Week units - ValuesTimestampdiff ( +,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  - --Month units the ValuesTimestampdiff ( -,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  the --Quarterly Units the ValuesTimestampdiff ( -,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));  the --Year as Unit - ValuesTimestampdiff ( the,Char( Current timestamp - timestamp('2010-01-01-00.00.00')));

DB2 Time Function Daquan

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.