I have already asked this question, but i changes in my table of #MonthDate,please go through
I want ,when day(15-06-2022) before From_Date, Duty is zero and after day(20-06-2022) from To_Date Duty is Zero ,then From_Date and To_Date ,Duty Column will be marked with 2 else if 15-06-2022 or 20-06-2022 is marked with 1 then From_Date and To_Date ,Duty Column will be marked with 1.
below is data
Create table #EmpMaster (EnrollNumber int, empName varchar(50))
Create table #MonthDate (Day varchar(50),Date date,Holiday varchar(50),From_Date date,To_Date date)
Create table #tbl_Emp_Register (EnrollNumbeR int,Date date,Day varchar(5),Duty int)
Insert into #EmpMaster values (10001,'ALi')
Insert into #MonthDate values ('Sun','2022-11-12',null,null,null)
Insert into #MonthDate values ('Mon','2022-11-13',null,null,null)
Insert into #MonthDate values ('Tue','2022-11-14',null,null,null)
Insert into #MonthDate values ('Wed','2022-11-15',null,null,null)
Insert into #MonthDate values ('Thu','2022-11-16','H','2022-11-16','2022-11-19') Insert into #MonthDate values ('Fri','2022-11-17','H','2022-11-16','2022-11-19') Insert into #MonthDate values ('Sat','2022-11-18','H','2022-11-16','2022-11-19') Insert into #MonthDate values ('Sun','2022-11-19','H','2022-11-16','2022-11-19') Insert into #MonthDate values ('Mon','2022-11-20',null,null,null)
Insert into #MonthDate values ('Tue','2022-11-21',null,null,null) Insert into #tbl_Emp_Register values (10001,'2022-11-12','Sun',1)
Insert into #tbl_Emp_Register values (10001,'2022-11-13','Mon',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-14','Tue' ,1) Insert into #tbl_Emp_Register values (10001,'2022-11-15','Wed' ,1) Insert into #tbl_Emp_Register values (10001,'2022-11-16' ,'Thu',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-17','Fri',0) Insert into #tbl_Emp_Register values (10001,'2022-11-18','Sat',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-19','Sun',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-20','Mon',0)
Insert into #tbl_Emp_Register values (10001,'2022-11-21','Tue' ,1)
![User's image](https://learn-attachment.microsoft.com/api/attachments/305725dc-f9e5-467f-a9af-0e5d583bdbae?platform=QnA)