-- MICROSECOND()
SELECT MICROSECOND('0001-01-01 00:00:00.100000') FROM SYSIBM.SYSDUMMY1;
SELECT MICROSECOND('0001-01-01 12:35:30.100001') FROM SYSIBM.SYSDUMMY1;

-- SECOND()
SELECT SECOND('0001-01-01 12:35:30.100001') FROM SYSIBM.SYSDUMMY1;

-- MINUTE()
SELECT MINUTE('0001-01-01 12:35:30.100001') FROM SYSIBM.SYSDUMMY1;
SELECT MINUTE('0001-01-01 12:35:30.100001+02:00') FROM SYSIBM.SYSDUMMY1;

-- HOUR()
SELECT HOUR('0001-01-01 12:35:30.100001') FROM SYSIBM.SYSDUMMY1;
SELECT HOUR('0001-01-01 12:35:30.100001+02:00') FROM SYSIBM.SYSDUMMY1; -- WRONG

-- DAY()
SELECT DAY('0001-01-01 12:35:30.100001') FROM SYSIBM.SYSDUMMY1;
SELECT DAY('1000-01-01') FROM SYSIBM.SYSDUMMY1;
SELECT DAY('0004-02-29') FROM SYSIBM.SYSDUMMY1;

-- YEAR()
SELECT YEAR('0001-01-01') FROM SYSIBM.SYSDUMMY1;
SELECT YEAR(CURRENT_TIMESTAMP) FROM SYSIBM.SYSDUMMY1;

-- DAYS()
SELECT DAYS('1000-01-01') FROM SYSIBM.SYSDUMMY1;
SELECT DAYS('0000-01-01') FROM SYSIBM.SYSDUMMY1; -- ERROR
SELECT DAYS('0001-01-01') FROM SYSIBM.SYSDUMMY1;

-- MONTHS_BETWEEN()
SELECT MONTHS_BETWEEN('0002-01-01', '0001-01-01') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('0002-01-01', '0001-01-02') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('0002-01-01', '0001-01-03') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('0003-01-01', '0001-01-02') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2008-01-17', '2008-02-17') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2008-02-17', '2008-03-17') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2008-02-20', '2008-01-17') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2008-01-17', '2008-02-20') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2008-02-20', '2008-01-20') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2014-07-09', '2014-06-10') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2014-07-09 14:00:00.000000', '2014-06-10') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2014-07-09 14:30:00.000000', '2014-06-10') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2014-07-09 14:30:30.000000', '2014-06-10') FROM SYSIBM.SYSDUMMY1;
SELECT MONTHS_BETWEEN('2014-07-09 14:30:30.000000+06:00', '2014-06-10') FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(MONTHS_BETWEEN('2008-03-29', '2008-02-29')*31,2) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(MONTHS_BETWEEN('2008-03-30', '2008-02-29')*31,2) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(MONTHS_BETWEEN('2008-03-31', '2008-02-29')*31,2) FROM SYSIBM.SYSDUMMY1; -- WRONG ("The result 
-- is not 33 because both dates are the last day of their respective month, and so the result is only based 
-- on the year and month portions.")

-- LOCATE()
SELECT LOCATE('N', 'DINING') FROM SYSIBM.SYSDUMMY1;

-- TRANSLATE()
SELECT TRANSLATE('12345', 'ax', '143') FROM SYSIBM.SYSDUMMY1;
SELECT TRANSLATE('Hanauma Bay') FROM SYSIBM.SYSDUMMY1;
SELECT TRANSLATE('Hanauma Bay', 'j', 'B'	) FROM SYSIBM.SYSDUMMY1;
SELECT TRANSLATE('Hanauma Bay', 'ei', 'aa') FROM SYSIBM.SYSDUMMY1;
SELECT TRANSLATE('Hanauma Bay', 'r', 'Bu') FROM SYSIBM.SYSDUMMY1;

-- INTEGER()/INT()
SELECT INTEGER(1.00) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(1.50) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(1.99) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(2.00) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(1.99e0) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(2.00e0) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(2.00) FROM SYSIBM.SYSDUMMY1;
SELECT INTEGER(1) FROM SYSIBM.SYSDUMMY1;
SELECT DOUBLE(1.00) FROM SYSIBM.SYSDUMMY1;
SELECT CHAR(1.00) FROM SYSIBM.SYSDUMMY1;

-- HEX()
SELECT HEX('000020') FROM SYSIBM.SYSDUMMY1;
SELECT HEX(000020) FROM SYSIBM.SYSDUMMY1; -- WRONG

-- ROUND()
SELECT ROUND(873.726, 2) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(873.726, 1) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(873.726, 0) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(873.726, -1) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(873.726, -2) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(873.726, -3) FROM SYSIBM.SYSDUMMY1;
SELECT ROUND(873.726, -4) FROM SYSIBM.SYSDUMMY1;

-- VALUE()
SELECT VALUE(1) FROM SYSIBM.SYSDUMMY1; -- DB2 ERROR
SELECT VALUE(NULL) FROM SYSIBM.SYSDUMMY1; -- DB2 ERROR
SELECT VALUE(NULL, NULL) FROM SYSIBM.SYSDUMMY1; -- DB2 ERROR
SELECT VALUE(NULL, 1, NULL) FROM SYSIBM.SYSDUMMY1; -- DB2 ERROR
SELECT VALUE(NULL, '1', NULL) FROM SYSIBM.SYSDUMMY1; -- DB2 ERROR

-- ^= operator
SELECT 1 FROM SYSIBM.SYSDUMMY1 WHERE 1 ^= 2;
SELECT 1 FROM SYSIBM.SYSDUMMY1 WHERE 1 ^= 1;

-- !! operator
SELECT 'FOO' !! ' BAR' FROM SYSIBM.SYSDUMMY1;

-- misc tests
SELECT INT(5) - (INT(5) / 1000) * 1000 FROM SYSIBM.SYSDUMMY1;
SELECT 5 / 1000 FROM SYSIBM.SYSDUMMY1;
SELECT 5.0 / 1000 FROM SYSIBM.SYSDUMMY1;
--
SELECT * FROM SYSIBM.SYSDUMMY1 FETCH FIRST 1 ROWS ONLY;