-- identify the calendar code
SELECT organization_code,
calendar_code,
negative_inv_receipt_code,
stock_locator_control_code,
organization_id
FROM mtl_parameters
WHERE organization_code = '313'
-- check if it is a working day time
SELECT 1
FROM bom_calendars cal,
bom_shift_dates sd,
bom_shift_times st
WHERE cal.calendar_code = 'GIL_FC_CMO'--c_calendar_code
AND sd.calendar_code = cal.calendar_code
AND st.calendar_code = sd.calendar_code
AND sd.shift_num = st.shift_num
-- B4610901, Rajesh Patangya 15-Sep-2005
AND (sd.shift_date + (st.from_time/86400)) <= '30-JAN-2015'
AND DECODE(
SIGN(st.from_time - st.to_time),
1,(sd.shift_date+1), sd.shift_date
) + (st.to_time/86400) >= '30-JAN-2015'
AND sd.seq_num IS NOT NULL
SELECT organization_code,
calendar_code,
negative_inv_receipt_code,
stock_locator_control_code,
organization_id
FROM mtl_parameters
WHERE organization_code = '313'
-- check if it is a working day time
SELECT 1
FROM bom_calendars cal,
bom_shift_dates sd,
bom_shift_times st
WHERE cal.calendar_code = 'GIL_FC_CMO'--c_calendar_code
AND sd.calendar_code = cal.calendar_code
AND st.calendar_code = sd.calendar_code
AND sd.shift_num = st.shift_num
-- B4610901, Rajesh Patangya 15-Sep-2005
AND (sd.shift_date + (st.from_time/86400)) <= '30-JAN-2015'
AND DECODE(
SIGN(st.from_time - st.to_time),
1,(sd.shift_date+1), sd.shift_date
) + (st.to_time/86400) >= '30-JAN-2015'
AND sd.seq_num IS NOT NULL