Feature #2578 ยป QueryPWSMinovES.sql
| 1 |
DECLARE @now VARCHAR(8) |
|---|---|
| 2 |
SET @now = dbo.fn_formatdatetime(GETDATE(), 'yyyymmdd') |
| 3 |
|
| 4 |
DECLARE @toinsertmd125 TABLE |
| 5 |
(
|
| 6 |
EmployeeID VARCHAR(20) |
| 7 |
,StartDate VARCHAR(20) |
| 8 |
,EndDate VARCHAR(20) |
| 9 |
,DayType VARCHAR(20) |
| 10 |
,PublicHoliday VARCHAR(20) |
| 11 |
,Notes VARCHAR(50) |
| 12 |
,CreateBy VARCHAR(50) |
| 13 |
,CreateDate VARCHAR(50) |
| 14 |
,ChangeBy VARCHAR(50) |
| 15 |
,ChangeDate VARCHAR(50) |
| 16 |
)
|
| 17 |
insert into @toinsertmd125 |
| 18 |
select md25.EmployeeID, cal.DateSpecified, cal.DateSpecified,cal.DayType,cal.PublicHoliday, '','system' , FORMAT(getdate(),'yyyyMMddHHmmss'), 'system',FORMAT(getdate(),'yyyyMMddHHmmss') from PHRPA0025 md25 |
| 19 |
left join PHRTMWSCAL cal on md25.WorkScheduleType = cal.WorkScheduleType |
| 20 |
and cal.year= '2024' |
| 21 |
where md25.WorkScheduleType = '5D8H' |
| 22 |
-- filter berdasarkan generate ws pertahun
|
| 23 |
--and md25.StartDate = '20240101'
|
| 24 |
-- filter berdasarkan generate lebih dari 1 tahun dan hanya yg aktif saja yaitu yg 99991231
|
| 25 |
AND md25.StartDate <= @now |
| 26 |
AND md25.EndDate >= @now |
| 27 |
|
| 28 |
INSERT INTO dbo.PHRPA0125 |
| 29 |
SELECT DISTINCT [StartDate],[EndDate],[EmployeeID],[DayType],[PublicHoliday],[Notes],[CreateBy],[CreateDate],[ChangeBy],[ChangeDate] FROM?@toinsertmd125 |
| 30 |
|