DB2 time function statement [SQL] Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/-- > -- Get the current date: select current date from sysibm. sysdummy1; values current date; -- Obtain the current date select current time from sysibm. sysdummy1; values current time; -- Obtain the current timestamp select current timestamp from sysibm. sysdummy1; values current timestamp; -- to adjust the current time or current time stamp to GMT/CUT, subtract the current time or time stamp from the current time zone register: values current time-current timezone; values current timestamp-current timezone; -- get the current year values year (current timestamp); -- get the current month values month (current timestamp ); -- Get the current day's values day (current timestamp); -- get the current values hour (current timestamp); -- get the minute's values minute (current timestamp ); -- Obtain the second values second (current timestamp); -- Obtain the millisecond values microsecond (current timestamp); -- extract the date and time values date (current timestamp) from the time stamp ); values VARCHAR_FORMAT (current TIMESTAMP, 'yyyy-mm-dd'); values char (current date); values time (current timestamp ); -- calculate the execution date and time values current date + 1 year; values current date + 3 years + 2 months + 15 days; values current time + 5 hours-3 minutes + 10 seconds; -- calculate the number of days between two dates values days (current date)-days (date ('1970-02-20 '); -- replace the time and date with the string values char (current date ); values char (current time); -- convert the string to a date or time value values timestamp ('2017-03-09-22.43.00.000000'); values timestamp ('2017-03-09 22:44:36 '); values date ('1970-03-09 '); values date ('1970/123'); values time ('22: 45: 27'); values time ('22. 45.27 '); -- calculate the time difference between two timestamps: -- the fractional part of the second is in the unit of values timestampdiff (1, char (current timestamp-timestamp ('2017-01-01-00.00.00 '); -- seconds are measured in values timestampdiff (2, char (current timestamp-timestamp ('2017-01-01-00.00.00 '); -- unit: values timestampdiff (4, char (current timestamp-timestamp ('2017-01-01-00.00.00 '))); -- hour is the unit of values timestampdiff (8, char (current timestamp-timestamp ('2017-01-01-00.00.00 '); -- day is the unit of values timestampdiff (16, char (current timestamp-timestamp ('1970-01-01-00.00.00 '); -- weekly value unit: values timestampdiff (32, char (current timestamp-timestamp ('1970-01-01-00.00.00 '); -- the unit of month is values timestampdiff (64, char (current timestamp-timestamp ('2017-01-01-00.00.00 '); -- quarterly Value Unit: values timestampdiff (2010, char (current timestamp-timestamp ('1970-01-01-00.00.00 '); -- the unit of year is values timestampdiff (2010, char (current timestamp-timestamp ('2017-01-01-00.00.00 ')));