Re: Date - Time Into Processing Time
Date: 1996/02/26
Message-ID: <4gs5i3$b8s_at_inferno.mpx.com.au>#1/1
In article <4g28q5$iuu_at_ra.nrl.navy.mil>, WEAVERI_at_AWCNET.EGLIN.AF.MIL wrote:
>We are about to fill out disk with the code for this project!
>We have a table: Prj_start date;
> Prj_end date;
> Prj_days number;
> Prj_Hours number;
>The project requires that the Prj_end minus Prj_start, then calculate
>the days and hours it took (minus the week-ends) to complete the
>project.
>Question: Are there any ORACLE internals for computing week-end stuff?
>Question: Can any one provide some pointers?
>
You can use the to_char function to determine whether or not a day is Saturday
or Sunday (eg select to_char(sysdate, 'Day') from dual returns Monday,
Tuesday, Wednesday etc).
However, this would mean that you are effectively hard-coding into the query which days are days worked on the project. Possibly a better solution is to create a table which allows you to record whether or not a day is a working day (don't forget public hols etc) and to do a look up in here to determine whether or not to include it in the total number of days worked, eg something (vaguely) aling the lines of :
select sum(to_number(decode(working_day_yn, 'Y', 1, 0))) from working_days, project where work_date between proj_start and proj_end etc ...
Regards,
-- Phill Edwards -- Received on Mon Feb 26 1996 - 00:00:00 CET