calcular fecha
hola a todos
espero me puedan ayudar
necesito saber como puedo sumarle un año
a una determinada fecha.
para ser mas concreto:
tengo nu texbox, en el cual introduzco los datos
asi: ddmmaa (181202)y mediante una funcion, se guarda en la base de datos asi: 18/12/02, lo que necesito es sumarle a esa fecha un año, es decir que en el siguiente textbox aparesca 18/12/03.
gracias.
el codigo es el siguiente:
'VALIDO LOS CAMPOS DE LAS FECHAS
Private Sub TxtfInclusion_LostFocus()
TxtfInclusion.Text = fFecha(TxtfInclusion.Text)
If Not IsDate(TxtfInclusion.Text) Then
mensaje$ = " Fecha Incorrecta, Desea Continuar? "
reply = MsgBox(mensaje$, vbYesNo, "Atención")
If reply = vbYes Then
TxtfInclusion.Text = ""
TxtfInclusion.SetFocus
Else
' Limpia los campos
Limpiar (Me)
txt1.SetFocus
End If
End If
End Sub
'FUNCION
Function fFecha(ByVal Vfecha As String) As String
fFecha = Vfecha
If InStr(Vfecha, "/") = 0 Then
If Len(Vfecha) = 6 Then
fFecha = Mid(Vfecha, 1, 2) & "/" & Mid(Vfecha, 3, 2) & "/" & Right(Vfecha, 2)
End If
If Len(Vfecha) = 8 Then ' si el año tiene 4 digitos
fFecha = Mid(Vfecha, 1, 2) & "/" & Mid(Vfecha, 3, 2) & "/" & Right(FNacimiento, 4)
End If
End If
End Function
ESPERO SUS RESPUESTAS
espero me puedan ayudar
necesito saber como puedo sumarle un año
a una determinada fecha.
para ser mas concreto:
tengo nu texbox, en el cual introduzco los datos
asi: ddmmaa (181202)y mediante una funcion, se guarda en la base de datos asi: 18/12/02, lo que necesito es sumarle a esa fecha un año, es decir que en el siguiente textbox aparesca 18/12/03.
gracias.
el codigo es el siguiente:
'VALIDO LOS CAMPOS DE LAS FECHAS
Private Sub TxtfInclusion_LostFocus()
TxtfInclusion.Text = fFecha(TxtfInclusion.Text)
If Not IsDate(TxtfInclusion.Text) Then
mensaje$ = " Fecha Incorrecta, Desea Continuar? "
reply = MsgBox(mensaje$, vbYesNo, "Atención")
If reply = vbYes Then
TxtfInclusion.Text = ""
TxtfInclusion.SetFocus
Else
' Limpia los campos
Limpiar (Me)
txt1.SetFocus
End If
End If
End Sub
'FUNCION
Function fFecha(ByVal Vfecha As String) As String
fFecha = Vfecha
If InStr(Vfecha, "/") = 0 Then
If Len(Vfecha) = 6 Then
fFecha = Mid(Vfecha, 1, 2) & "/" & Mid(Vfecha, 3, 2) & "/" & Right(Vfecha, 2)
End If
If Len(Vfecha) = 8 Then ' si el año tiene 4 digitos
fFecha = Mid(Vfecha, 1, 2) & "/" & Mid(Vfecha, 3, 2) & "/" & Right(FNacimiento, 4)
End If
End If
End Function
ESPERO SUS RESPUESTAS
