Inicio » 2012»Noviembre»30 » Calcula dias habiles de un rango de dos fechas visual .net
9:30 PM
Calcula dias habiles de un rango de dos fechas visual .net
Function El_Dia_es_habil(ByVal fechaIni As Date, ByVal fechaFin As Date) As Integer Dim i As Integer Dim sDiasNoHabil As Integer Dim sDias As Integer Dim DayOfWeek As FirstDayOfWeek
i = 1 Do While i <= sDias fechaFin = DateAdd(DateInterval.Day, i, fechaIni) If DateAndTime.Weekday(fechaFin, DayOfWeek) = 7 Or DateAndTime.Weekday(fechaFin, DayOfWeek) = 1 Then 'sDias = sDias + 1 sDiasNoHabil = sDiasNoHabil - 1 Else If Verifica_Dia_Festivo(fechaFin) = True Then 'sDias = sDias + 1 sDiasNoHabil = sDiasNoHabil - 1 End If End If i = i + 1 Loop El_Dia_es_habil = sDiasNoHabil End Function
Function Verifica_Dia_Festivo(ByVal sFecVerifica As Date) As Boolean Dim rsPermisos As ADODB.Recordset Dim cnBaseDatos As ADODB.Connection cnBaseDatos = CargaConexion()
rsPermisos = AbreRS("SELECT * FROM CatDiasFestivos WHERE DiaFestivo= '" & sFecVerifica & "' ", cnBaseDatos, 0) If Not rsPermisos.EOF Then Verifica_Dia_Festivo = True Else Verifica_Dia_Festivo = False End If End Function