222: , p_end_date IN date
223: , p_year_days IN number) IS
224: SELECT trunc (((p_start_date - 1) + (p_year_days / p_number_per_fiscal_year) * (level - 1)) + 1)
225: , trunc (((p_start_date - 1) + ((p_year_days / p_number_per_fiscal_year) * (level - 1))) + (p_year_days / p_number_per_fiscal_year))
226: FROM dual
227: WHERE trunc (((p_start_date - 1) + ((p_year_days / p_number_per_fiscal_year) * (level - 1))) + (p_year_days / p_number_per_fiscal_year)) <= to_date (p_end_date, fnd_profile.value ('ICX_DATE_FORMAT_MASK'))
228: CONNECT BY level <= (p_number_per_fiscal_year + 1);
229:
230: CURSOR c_get_monthly_periods(p_start_date DATE, p_end_date DATE)
230: CURSOR c_get_monthly_periods(p_start_date DATE, p_end_date DATE)
231: IS
232: SELECT add_months (p_start_date, (level - 1)) start_date
233: , (add_months (p_start_date, level) - 1) end_date
234: FROM dual
235: WHERE (add_months (p_start_date, level) - 1) <= p_end_date
236: CONNECT BY level <= ceil (months_between (p_end_date, p_start_date));
237:
238: CURSOR c_get_yearly_periods(p_start_date DATE, p_end_date DATE)
238: CURSOR c_get_yearly_periods(p_start_date DATE, p_end_date DATE)
239: is
240: SELECT add_months (p_start_date, ((level - 1)*12)) start_date
241: , (add_months (p_start_date, (level*12)) - 1) end_date
242: FROM dual
243: WHERE (add_months (p_start_date, (level*12)) - 1) <= p_end_date
244: CONNECT BY level <= (ceil (months_between (p_end_date, p_start_date))/12);
245:
246: CURSOR c_get_quarterly_periods(p_start_date DATE, p_end_date DATE)
246: CURSOR c_get_quarterly_periods(p_start_date DATE, p_end_date DATE)
247: is
248: SELECT add_months (p_start_date, ((level - 1)*12)) start_date
249: , (add_months (p_start_date, (level*12)) - 1) end_date
250: FROM dual
251: WHERE (add_months (p_start_date, (level*12)) - 1) <= p_end_date
252: CONNECT BY level <= (ceil (months_between (p_end_date, p_start_date))/12);
253:
254: --change the query a bit
258: SELECT
259: trunc(((p_start_date - 1) + p_duration_in_days * (level - 1)) + 1) startdate,
260: trunc(((p_start_date - 1) + (p_duration_in_days * (level - 1))) + p_duration_in_days) enddate
261: FROM
262: dual
263: WHERE trunc(((p_start_date - 1) + (p_duration_in_days * (level - 1))) + p_duration_in_days) <= p_end_date
264: CONNECT BY level <= trunc(p_end_date - p_start_date + 1) / (p_duration_in_days);
265:
266:
2459: THEN
2460: l_start_time := l_start_date;
2461: END IF;
2462: END IF;
2463: -- select mod(to_number(to_char(l_start_date,'j'))- to_number(to_char(to_date('03-jan-2012'),'j')),5) from dual
2464: END IF;
2465:
2466: OPEN c_get_duration_periods(l_duration_in_days, l_start_time, l_timecard(i).stop_time);
2467: LOOP