Oracle PL/SQL を使用して、期日とタスクを完了するために必要な作業時間を使用して、タスクの開始日を計算する必要があります。
2012 年 7 月 24 日 17:00 が期限で、タスクを完了するのに必要な時間は 20 時間で、勤務時間は午前 8 時から午後 5 時まで (昼食は 1 時間 - 1 日最大 8 時間) で、PL で計算する必要があります。 /SQL 開始日時は... 2012 年 7 月 22 日 13:00 になるはずです。
次のコードが出発点になる可能性があります。
function task_start_date(
p_due_date date,
p_working_hours number
) return date
is
l_start_date date;
begin
-- Subtract full days
l_start_date := p_due_date - trunc(p_working_hours / 8);
-- Subtract remaining hours
l_start_date := l_start_date - mod(p_working_hours, 8) / 24;
-- Fix date if the due date is before 8AM
if to_number(to_char(l_start_date, 'HH24')) < 8 then
l_start_date := l_start_date - 15 / 24;
end if;
return l_start_date;
end task_start_date;
この関数は、ランチタイムを一貫して考慮していないことに注意してください。ランチタイムを正確に定義し、それに応じて関数を調整する必要があります。