Fröt
Junior Member
No
Posts: 16
37 / / –
Joined: Feb 2005
Status: Away
|
O.P. RE: Help to a newbie?
code:
Function DiferenciaEnFechas(pdFechaBase As Date, pdFecha As Date) As String
Dim dFechaAux As Date
Dim iYear As Integer, iMes As Integer, iDia As Integer
Dim iYearFinal As Integer
Dim iMesFinal As Integer
Dim iDiaFinal As Integer
Dim sTiempo As String, sAux As String
iDia = DatePart("d", pdFecha)
iMes = Month(pdFechaBase)
iYear = Year(pdFechaBase)
dFechaAux = DateSerial(iYear, iMes, iDia)
iDiaFinal = DateDiff("d", dFechaAux, pdFechaBase)
iMes = DateDiff("m", pdFecha, pdFechaBase)
Select Case iMes
Case Is > 0
iYearFinal = iMes \ 12
iMesFinal = iMes Mod 12
If iDiaFinal < 0 Then
If Month(dFechaAux) <> Month(pdFechaBase) Then
iDiaFinal = 31 - (DatePart("d", DateAdd("d", -1, DateSerial(iYear, Month(dFechaAux), 1))))
dFechaAux = DateAdd("m", -1, dFechaAux)
dFechaAux = DateAdd("d", -iDiaFinal, dFechaAux)
Else
dFechaAux = DateAdd("m", -1, dFechaAux)
End If
iDiaFinal = DateDiff("d", dFechaAux, pdFechaBase)
If iMesFinal > 0 Then
iMesFinal = iMesFinal - 1
Else
If iYearFinal > 0 Then
iYearFinal = iYearFinal - 1
iMesFinal = 11
End If
End If
End If
sTiempo = "Pasado: "
Case Is = 0
iYearFinal = 0
iMesFinal = 0
If iDiaFinal < 0 Then 'Futuro
iDiaFinal = DateDiff("d", pdFechaBase, dFechaAux)
sTiempo = "Futuro: "
ElseIf iDiaFinal = 0 Then 'HOY
sTiempo = "HOY: "
Else 'Pasado
sTiempo = "Pasado: "
End If
Case Else 'Futuro
iMes = DateDiff("m", pdFechaBase, pdFecha)
iYearFinal = iMes \ 12
iMesFinal = iMes Mod 12
If iDiaFinal > 0 Then
dFechaAux = DateAdd("m", 1, dFechaAux)
iDiaFinal = DateDiff("d", pdFechaBase, dFechaAux)
If iMesFinal > 0 Then
iMesFinal = iMesFinal - 1
Else
If iYearFinal > 0 Then
iYearFinal = iYearFinal - 1
iMesFinal = 11
End If
End If
Else
iDiaFinal = DateDiff("d", pdFechaBase, dFechaAux)
End If
sTiempo = "Futuro: "
End Select
sAux = Str(iYearFinal)
If iYearFinal = 1 Then
sAux = sAux & " Ańo, "
Else
sAux = sAux & " Ańos, "
End If
sAux = sAux & Str(iMesFinal)
If iMesFinal = 1 Then
sAux = sAux & " Mes, "
Else
sAux = sAux & " Meses, "
End If
sAux = sAux & Str(iDiaFinal)
If iDiaFinal = 1 Then
sAux = sAux & " Día"
Else
sAux = sAux & " Dia"
End If
DiferenciaEnFechas = sTiempo & sAux
Dim a, b, c As Integer
a = Left(Right(DiferenciaEnFechas, 6), 2)
b = Left(Right(DiferenciaEnFechas, 16), 1)
If Left(a, 1) = " " Then
a = Right(a, 1)
End If
If b = " " Then
b = 0
End If
c = a + (b * 30)
DiferenciaEnFechas = c
End Function
my function is above!
can anybody send the plugin code for me to understand at last?
i think i wanted very much things.
This post was edited on 02-11-2005 at 09:41 PM by Fröt.
|
|