DROP TABLE IF EXISTS mmcallister.TestDateMath;
CREATE TABLE mmcallister.TestDateMath (
        Product VARCHAR(36) NOT NULL,
        DateNumId INTEGER NOT NULL,
        DateId DATE NULL,
        ColVal VARCHAR(50) NULL,
        CONSTRAINT TestDateMath_PK PRIMARY KEY (Product,DateNumId)
);

-- MyProduct

UPSERT INTO mmcallister.TestDateMath
VALUES ('MyProduct'
	   ,20150228
	   ,TO_DATE('2015-02-28','yyyy-MM-dd')
	   ,'MyProduct - 28-FEB-2015'
	   );

UPSERT INTO mmcallister.TestDateMath
VALUES ('MyProduct'
	   ,20150331
	   ,TO_DATE('2015-03-31','yyyy-MM-dd')
	   ,'MyProduct - 31-MAR-2015'
	   );

UPSERT INTO mmcallister.TestDateMath
VALUES ('MyProduct'
	   ,20160229
	   ,TO_DATE('2016-02-29','yyyy-MM-dd')
	   ,'MyProduct - 29-FEB-2016'
	   );

UPSERT INTO mmcallister.TestDateMath
VALUES ('MyProduct'
	   ,20160331
	   ,TO_DATE('2016-03-31','yyyy-MM-dd')
	   ,'MyProduct - 31-MAR-2016'
	   );

-- AnotherProduct

UPSERT INTO mmcallister.TestDateMath
VALUES ('AnotherProduct'
	   ,20150228
	   ,TO_DATE('2015-02-28','yyyy-MM-dd')
	   ,'AnotherProduct - 28-FEB-2015'
	   );

UPSERT INTO mmcallister.TestDateMath
VALUES ('AnotherProduct'
	   ,20150331
	   ,TO_DATE('2015-03-31','yyyy-MM-dd')
	   ,'AnotherProduct - 31-MAR-2015'
	   );

UPSERT INTO mmcallister.TestDateMath
VALUES ('AnotherProduct'
	   ,20160229
	   ,TO_DATE('2016-02-29','yyyy-MM-dd')
	   ,'AnotherProduct - 29-FEB-2016'
	   );

UPSERT INTO mmcallister.TestDateMath
VALUES ('AnotherProduct'
	   ,20160331
	   ,TO_DATE('2016-03-31','yyyy-MM-dd')
	   ,'AnotherProduct - 31-MAR-2016'
	   );

select *
from mmcallister.TestDateMath
where Product = 'MyProduct'
and DateNumId in (20160331,20160331-10001,20160331-10000,20160331-9999);