Visual Basic - FUNCION FECHA

Life is soft - evento anual de software empresarial
 
Vista:

FUNCION FECHA

Publicado por MARIA (12 intervenciones) el 28/10/2004 09:12:06
Hola a todos y gracias por adelantado.
Quisiese saber si hay alguna funcion que teniendo un formato de fecha "mmyy" (mes_año) pudiese restar un mes a la fecha.
Por ejemplo teniendo la fecha "0904" (Septiembre del 2004), restandole 1 me diese "0804"(Agosto del 2004).
Como yo no sabía ninguna funcion usaba este código pero es un lio porque tienes que controlar cuando cambias de año y añadir un cero delante de los meses menores de 10:

strBase = Month(Date)
If Len(strBase) < 2 Then
If strBase = 0 Then
strBase = "12"
strBase = strBase & "" & Format((Year(Date) - 1), "yy")
Else
strBase = 0 & strBase
strBase = strBase & "" & Format(Year(Date), "yy")
End If
Else
strBase = strBase & "" & Format(Year(Date), "yy")
End If

Puede ayudarme alguien?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

RE:FUNCION FECHA

Publicado por dventas (137 intervenciones) el 28/10/2004 09:26:51
Dim a As Date
Dim dia As String

dia = "0804"

dia = "01/" & Left(dia, 2) & "/" & Right(dia, 2)

a = CDate(Format(dia, "dd/mm/yy"))
a = DateAdd("m", 1, a)
MsgBox Format(a, "mmyy")
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar