I am working on an Alteryx workflow to replicate SQL logic for calculating Days Revoked After Termination. The logic should compute:
ALTER FUNCTION [dbo].[CalculateWorkingDays](@StartDate DATE, @EndDate DATE)
RETURNS INT
AS
BEGIN
DECLARE @TotalDays INT = DATEDIFF(day, @StartDate, @EndDate);
DECLARE @WeekendDays INT = 0;
DECLARE @CurrentDate DATE = @StartDate;
WHILE @CurrentDate < @EndDate
BEGIN
IF DATEPART(weekday, @CurrentDate) IN (1, 7)
BEGIN
SET @WeekendDays = @WeekendDays + 1;
END
SET @CurrentDate = DATEADD(day, 1, @CurrentDate);
END
RETURN @TotalDays - @WeekendDays;
END;
(Start Date = Termination Date
End Date = Effective Date)
Expected behavior:
- If Termination Date = 2025-05-09 and Effective Date = 2025-05-10 →
TotalDays = 1, WeekendDays = 0, Result = 1
the workflow i have created has been attached here. Appreciate if anyone could help on this