Created
March 24, 2021 23:50
-
-
Save pablotolentino/5b85e0ad90132b119bddb93d346f050d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION [dbo].[DiasLaborales] | |
(@FechaInicial DATE, | |
@FechaFinal DATE ) | |
RETURNS INT | |
AS | |
BEGIN | |
DECLARE @fecha DATE | |
DECLARE @diaslaborales int | |
SET @fecha = @FechaInicial | |
SET @diaslaborales = 0 | |
WHILE (@fecha<>DATEADD(day,1,@FechaFinal)) | |
BEGIN | |
IF (DATEPART(dw,@fecha) NOT IN (7,1)) | |
BEGIN | |
SET @diaslaborales = @diaslaborales +1 | |
END | |
SET @fecha = DATEADD(day,1,@fecha) | |
END | |
RETURN @diaslaborales | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment