Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Determine number working day between two dates - response (1) by bikky6

$
0
0

Hi
I have created the below tables for your scenario.Let me know if it solves your purpose.
CT HOL(START_DATE DATE,END_DATE DATE);
INS INTO HOL VALUES('2013-06-03','2013-06-13');
INS INTO HOL VALUES('2013-06-06','2013-06-12');
INS INTO HOL VALUES('2013-06-05','2013-06-22');
CT LIST(HOL_DATE DATE)
INS INTO LIST VALUES('2013-06-01');
INS INTO LIST VALUES('2013-06-02');
INS INTO LIST VALUES('2013-06-09');
INS INTO LIST VALUES('2013-06-08');
INS INTO LIST VALUES('2013-06-15');
INS INTO LIST VALUES('2013-06-16');
INS INTO LIST VALUES('2013-06-22');
INS INTO LIST VALUES('2013-06-23');
 SEL DT.START_DATE,DT.END_DATE,COUNT(DT.WORKING_DAYS)
FROM
(SEL START_DATE,END_DATE , L.HOL_DATE,CASE WHEN L.HOL_DATE BETWEEN H.START_DATE AND H.END_DATE THEN 'Y' ELSE 'N' END  AS WORKING_DAYS FROM HOL H,LIST L )DT
GROUP BY 1,2
WHERE DT.WORKING_DAYS='N'
 
--I did'nt join any key for two tables,you can join if anything in common.
Regards
KVB
 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>