Use Python/Pandas indexed date as condition in holiday list
Date : March 29 2020, 07:55 AM
this will help Here are some some thoughts... Say you have a list of holidays for 2016: cal = USFederalHolidayCalendar()
holidays = cal.holidays(start='2016-01-01', end='2016-12-31')
print holidays.size
10
idx = pd.DatetimeIndex(pd.date_range(start='2015-1-1',
end='2016-12-31', freq='30min'))
print idx.size
35041
idx[pd.DatetimeIndex(idx.date).isin(holidays.date)].size
480
|
Holiday Booking system, search for date - return a list of employees who are on holiday on that date
Date : March 29 2020, 07:55 AM
around this issue I seem to be asking a lot of questions on here recently, thanks in advance for any help! , i think you can use between for this purpose: declare @InputDate date='2016-09-16' --yur input date
select EmployeeId,
case when (select count(1) from EmployeeLeave
where (@InputDate between StartDate and EndDate)
and EmployeeLeave .EmployeeId=Employee .EmployeeId)>1 then 'True' else 'False' end as [OnHoliday],
case when ((select StartMidDay from EmployeeLeave
where (@InputDate between StartDate and EndDate)
and EmployeeLeave .EmployeeId=Employee .EmployeeId))=0.5 then 'True' else 'False' end as [IsHalf] ,
from Employee
|
Sql Server 2008 Exclude Company Holiday from DateDiff
Date : March 29 2020, 07:55 AM
With these it helps After 2 case statements you can add below statement to subtract no of days from holiday Calendar table. - (select ISNULL(count(1),0) from Cal where Cal.Holiday between ALERTS_CREATE_DT AND CreatedDate )
|
If date is a holiday, then add days to date until date is no holiday
Date : March 29 2020, 07:55 AM
I wish did fix the issue. If day x is a holiday, then add days to day x until it is not a holiday. , You missed assigning and updating lastday. def is_lastday_holiday(lastday):
while lastday in sorted(holidays.AT(years=2017)):
lastday = lastday + timedelta(days=1)
return lastday
lastday += timedelta(days=1)
|
Exclude weekends and public holiday for SQL datediff
Tag : sql , By : hammer_1968
Date : March 29 2020, 07:55 AM
may help you . Like has been mentioned, the best way is to create a Calendar Table and then use the Working Days column, or whatever it is you called it, to calculate the difference. This is pseudo-SQL, in the absence of a working Calendar Table, but should get you there: SELECT YT.{YourColumn},
WD.WorkingDays
FROM YourTable YT
CROSS APPLY (SELECT COUNT(CT.DateKeyColumn) -1 AS WorkingDays --Minus 1, as we don't want to include the first day
FROM CalendarTable CT
WHERE CT.[DateColumn] >= YT.StartingDateColumn
AND CT.[DateColumn] <= YT.EndingDateColumn
AND CT.WorkingDay = 1) WD
|