Ver Mensaje Individual
  #8 (permalink)  
Antiguo 14/07/2010, 11:03
Avatar de Myakire
Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 3 meses
Puntos: 146
Respuesta: Valida solo dias Habiles

A ver que te parece esta primera aproximación, así a lo rápido creo que es lo que necesitas, pero pruébalo bien:

Código ASP:
Ver original
  1. <&#37;
  2.        
  3. if Request("FechaInicial") <> "" and Request("NumDias") <> "" Then
  4.    fFechaInicial    = CDate(Request("FechaInicial"))
  5.    iDiasIncrementar = CInt(Request("NumDias"))
  6.  
  7.    fFechaFinal      = DateAdd("d", iDiasIncrementar, CDate(Request("FechaInicial")))
  8.    iDiasEntreFechas = DateDiff("d", fFechaInicial, fFechaFinal)
  9.      iDiasNoHabiles   = FinesDeSemana(fFechaInicial, fFechaFinal)
  10.      fFechaResultante = DateAdd("d", iDiasEntreFechas+iDiasNoHabiles, fFechaInicial)
  11.      
  12.    if FinesDeSemana(fFechaInicial, fFechaResultante) > 0 Then
  13.       fFechaResultante = DateAdd("d", iDiasEntreFechas+FinesDeSemana(fFechaInicial, fFechaResultante), fFechaInicial)
  14.      End If
  15.    
  16.      Response.Write "Fecha Inicial: " & Request("FechaInicial") & "<br>"
  17.      Response.Write "Dias hábiles a considerar: " & Request("NumDias") & "<br>"
  18.      Response.Write "<hr><br>"
  19.    Response.Write "Total de dias " & iDiasEntreFechas & "<br>"
  20.    Response.Write "Total de dias no hábiles: " & iDiasNoHabiles & "<br>"
  21.    Response.Write "Fecha resultante: " & fFechaResultante & "<br>"
  22.      Response.Write "<hr><br>"
  23. End If
  24.  
  25. Function FinesDeSemana(FechaIni, FechaFin)
  26.     aux = DateDiff("ww", FechaIni, FechaFin, vbSaturday) + DateDiff("ww", FechaIni, FechaFin, vbSunday)
  27.     If Weekday(FechaIni, vbSunday) = 1 Then aux = aux + 1 End if
  28.     If Weekday(FechaIni, vbSaturday) = 1 Then aux = aux + 1 End If
  29.     FinesDeSemana = aux
  30. End Function
  31. %>
  32. <form>
  33. Fecha Inicial: <input type="text" name="FechaInicial" value="01/01/2010"><br>
  34. Dias h&#225;biles: <input type="text" name="NumDias" value="20"><br>
  35. <input type="submit" value="Calcular">
  36. </form>