Project

General

Profile

Bug #349 » GetDurationLeave.sql

Tri Rizqiaty, 05/28/2021 04:27 PM

 
1
CREATE PROCEDURE GetDurationLeave
2
(
3
	@landscape VARCHAR(20)
4
	,@EmpID VARCHAR(20)
5
	,@StartDate VARCHAR(20)
6
	,@EndDate VARCHAR(20)
7
	,@AbsType VARCHAR(20)	
8
)
9
AS
10

    
11
--DECLARE @landscape VARCHAR(20)  = '100'
12
--DECLARE @EmpID VARCHAR(20) = '19021633'
13
--DECLARE @StartDate VARCHAR(20)  = '20210316'
14
--DECLARE @EndDate VARCHAR(20)  = '20210318'
15
--DECLARE @AbsType VARCHAR(20)  = '1000'
16

    
17
DECLARE @WSType VARCHAR(20)
18

    
19
SELECT @WSType = ws_type
20
FROM hr_md_emp_md0025
21
WHERE emp_id = @EmpID AND start_date <= @EndDate AND end_date >= @EndDate
22

    
23
SELECT COUNT(cal.datespecified) AS duration FROM hr_tm_workschedule_calender AS cal 
24
LEFT JOIN hr_tm_day_type AS daytp
25
	On daytp.day_type = cal.day_type
26
WHERE cal.workschedule_type = @WSType AND daytp.flag = 'WORK'
27
AND ( cal.datespecified BETWEEN @StartDate AND @EndDate )
(1-1/5)