Oracle calculates the cumulative cross-day time dimension TABLE from the beginning of the year to the current DATE: www.2cto.com SQL code CREATE TABLE D_TIME (D_DAY DATE NOT NULL, C_DAY_ID VARCHAR2 (8) NOT NULL, C_MONTH_ID VARCHAR2 (8) not null, C_MONTH_END_DATE VARCHAR2 (8) not null, C_YEAR_ID VARCHAR2 (8) not null, C_YEAR_END_DATE VARCHAR2 (8) not null); SQL code www.2cto.com select d1.c _ day_id, d1.d _ day sd_day, d1.d _ day-to_date (d1.c _ year_id | '000000', 'yyyymmdd') + 1 timespan, -- Cross days d1.c _ month_id, d1.c _ month_end_date, d1.c _ year_id, d1.c _ year_end_date, d2.d _ day d_day from d_time d1 inner join d_time d2 on d1.c _ year_id = d2.c _ year_id and d1.d _ day> = d2.d _ day where d1.d _ day> = to_date ('123' | | '01 ', 'yyyymmdd') -- import the start time and d1.d _ day <= last_day (to_date ('20170101', 'yyyymmdd') -- import the end time