sql date manipulation
Posted in 1996
Following up on a previous question regarding date range manipulation.... Take a table with 10 records. Each record has a begin date and an end date including maybe a person's name, work address, etc. The task is to see how many days each person has been on the job. It would be nice to be able to do a GROUP BY at the end, and see for each person their respective work time..... I expected using the datediff(dd,begin_date,end_date) routine in combination with something else perhaps a table with non-week-end dates.... However, I don't see any way to join them.... I am also worried... The io involved in loading a table and.... about a couple of odd events: i.e., the person may begin work on a week-end and end work on a week-end day. I don't want to count those days, but how would I join to the temporary table? To summarize: is it possible to create a result that look likes this: Name Begin Date End Date Total Days Work Days Jon 1/1/95 1/5/95 5 5 Mike 1/5/95 1/7/95 3 1 Jan 1/7/95 1/9/95 3 2 It's important to include the begin and end date in the total count. Can anyone help?