Index: src/test/java/org/teiid/query/function/TestFunction.java =================================================================== --- src/test/java/org/teiid/query/function/TestFunction.java (revision 4518) +++ src/test/java/org/teiid/query/function/TestFunction.java (working copy) @@ -847,6 +847,7 @@ @Test public void testTimestampAdd2() throws Exception { assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(NonReserved.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0))); } + @Test public void testTimestampDiffTimeStamp_FracSec_1() throws Exception { helpTestTimestampDiff(NonReserved.SQL_TSI_FRAC_SECOND, @@ -1006,7 +1007,43 @@ TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0, 0), new Long(31)); } + +// select TIMESTAMPDIFF(SQL_TSI_DAY,parseDate('2012-01-01', 'yyyy-MM-dd'),parseDate('2304-04-13', 'yyyy-MM-dd')) +// result = -106751. I would expected the answer to be 106752 + + @Test public void testParseTimestamp2() throws Exception { + helpTestParseTimestamp("2304-04-13", "yyyy-MM-dd", "{ts'2304-04-13 00:00:00.0'}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + + } + + @Test public void testTimestampDiffTimeStamp_ErrorUsingEndDate() throws Exception { + helpTestTimestampDiff(NonReserved.SQL_TSI_DAY, + TimestampUtil.createTimestamp(2012-1900, 0, 1, 0, 0, 0, 0), + TimestampUtil.createTimestamp(2304-1900, 3, 13, 0, 0, 0, 0), + new Long(106752)); + } + + @Test public void testTimestampDiffTimeStamp_ErrorUsingEndDate2304() throws Exception { + helpTestTimestampDiff(NonReserved.SQL_TSI_DAY, + FunctionMethods.parseTimestamp("2012-01-01", "yyyy-MM-dd"), + FunctionMethods.parseTimestamp("2304-04-13", "yyyy-MM-dd"), + new Long(106752)); + } + + @Test public void testTimestampDiffTimeStamp_ErrorUsingEndDate2262() throws Exception { + helpTestTimestampDiff(NonReserved.SQL_TSI_DAY, + FunctionMethods.parseTimestamp("2012-01-01", "yyyy-MM-dd"), + FunctionMethods.parseTimestamp("2262-04-12", "yyyy-MM-dd"), + new Long(106751)); + } + @Test public void testTimestampDiffTimeStamp_ErrorUsingEndDate2261() throws Exception { + helpTestTimestampDiff(NonReserved.SQL_TSI_DAY, + FunctionMethods.parseTimestamp("2012-01-01", "yyyy-MM-dd"), + FunctionMethods.parseTimestamp("2261-04-12", "yyyy-MM-dd"), + new Long(91046)); + } + @Test public void testTimestampDiffTimeStamp_Day_2() throws Exception { // Leap year helpTestTimestampDiff(NonReserved.SQL_TSI_DAY,