Date Operations / Arithmatic

Please visit this URL: http://www.ibm.com/developerworks/db2/library/techarticle/0211yip/0211yip3.html

SELECT current date, current date + 1 YEAR FROM SYSIBM.SYSDUMMY1;
SELECT current date, current date + 3 YEARS + 2 MONTHS + 15 DAYS FROM SYSIBM.SYSDUMMY1;
SELECT current date, current time + 5 HOURS - 3 MINUTES + 10 SECONDS FROM SYSIBM.SYSDUMMY1;
SELECT current date, days (current date) - days (date('1999-10-22')) FROM SYSIBM.SYSDUMMY1;

Other Functions:

SQL Date and Time Functions
DAYNAMEReturns a mixed case character string containing the name of the day (e.g., Friday) for the day portion of the argument.
DAYOFWEEKReturns the day of the week in the argument as an integer value in the range 1-7, where 1 represents Sunday.
DAYOFWEEK_ISOReturns the day of the week in the argument as an integer value in the range 1-7, where 1 represents Monday.
DAYOFYEARReturns the day of the year in the argument as an integer value in the range 1-366.
DAYSReturns an integer representation of a date.
JULIAN_DAYReturns an integer value representing the number of days from January 1, 4712 B.C. (the start of Julian date calendar) to the date value specified in the argument.
MIDNIGHT_SECONDSReturns an integer value in the range 0 to 86 400 representing the number of seconds between midnight and the time value specified in the argument.
MONTHNAMEReturns a mixed case character string containing the name of month (e.g., January) for the month portion of the argument.
TIMESTAMP_ISOReturns a timestamp value based on date, time or timestamp argument.
TIMESTAMP_FORMATReturns a timestamp from a character string that has been interpreted using a character template.
TIMESTAMPDIFFReturns an estimated number of intervals of the type defined by the first argument, based on the difference between two timestamps.
TO_CHARReturns a character representation of a timestamp that has been formatted using a character template. TO_CHAR is a synonym for VARCHAR_FORMAT.
TO_DATEReturns a timestamp from a character string that has been inter-preted using a character template. TO_DATE is a synonym for TIMESTAMP_FORMAT.
WEEKReturns the week of the year of the argument as an integer value in range 1-54. The week starts with Sunday.
WEEK_ISOReturns the week of the year of the argument as an integer value in the range 1-53.

No comments: