calcular la edad dando la fecha de nacimiento

16/02/2008 - 22:53 por Rayas Luis | Informe spam
supongamos que tengo la fecha de nacimento en la celda c3'-may-63, y quiero
determinar al dia de hoy (16-feb-08) la edad exacta es decir 44 años, ya que
le faltan 2 meses y dias para cumplir los 45.

Espero me puedan ayudar

Saludos desde Mexico

Preguntas similare

Leer las respuestas

#11 Edgar Brito
22/04/2008 - 18:19 | Informe spam
No se hagan bolas, les sugiero una funcion personalizada que calcule la edad.
ahi les va.

Function Edad(NACIMIENTO As date)
dim AÑOS as integer, alto as boolean, SIGUE as date
Set AÑOS = 0
Set alto = False
SIGUE = DateSerial(Year(NACIMIENTO) + 1, Month(NACIMIENTO),
Day(NACIMIENTO))
Do While alto = False
If NACIMIENTO <= SIGUE And Date >= SIGUE Then
AÑOS = AÑOS + 1
SIGUE = DateSerial(Year(SIGUE) + 1, Month(SIGUE), Day(SIGUE))
Else
alto = True
End If
Loop
End If
edad = AÑOS
End Sub

LUEGO DESDE CUALQUIER CELDA LLAMAS A LA FUNCION íAD(FECHA)

ES INFALIBLE SALUDOS
Respuesta Responder a este mensaje
#12 Héctor Miguel
23/04/2008 - 07:19 | Informe spam
hola, Edgar !

para que la propuesta (DE FUNCION personalizada) que expones, sea (realmente) "infalible"...
necesita que se le corijan dos o tres "detalles" (ahi te van):

1) no puedes usar la instruccion Set <variable_de_objeto> = ???
si tu <variable> NO fue declarada "como objeto" :-((

2) le esta "sobrando" una instruccion "End If" (la ante-penultima linea)

3) si estas definiendo un procedimiento "Function"...
NO puedes "terminarlo" con una instruccion "End Sub"

ya que hayas corregido estos puntos...
si comparas el "rendimiento" entre una UDF y las funciones integradas de excel (p.e.)

a) a tu funcion personalizada: =edad(fecha)
le toma 0.6 milisegundos obtener el resultado
(muchos "pasos" dentro del bucle Do While...Loop)

b) a la formula de la primera propuesta: =sifecha(fecha,hoy(),"y")
le toma 0.3 milisegundos obtener el resultado (la mitad que a una UDF)

(imagina usar una u otra para un rango "considerable" de celdas) :))

si cualquier duda (o informacion adicional)... comentas ?
saludos,
hector.

__ la propuesta original __
No se hagan bolas, les sugiero una funcion personalizada que calcule la edad.
ahi les va.

Function Edad(NACIMIENTO As date)
dim AÑOS as integer, alto as boolean, SIGUE as date
Set AÑOS = 0
Set alto = False
SIGUE = DateSerial(Year(NACIMIENTO) + 1, Month(NACIMIENTO), Day(NACIMIENTO))
Do While alto = False
If NACIMIENTO <= SIGUE And Date >= SIGUE Then
AÑOS = AÑOS + 1
SIGUE = DateSerial(Year(SIGUE) + 1, Month(SIGUE), Day(SIGUE))
Else
alto = True
End If
Loop
End If
edad = AÑOS
End Sub

LUEGO DESDE CUALQUIER CELDA LLAMAS A LA FUNCION íAD(FECHA)

ES INFALIBLE SALUDOS
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una pregunta AnteriorRespuesta Tengo una respuesta
Search Busqueda sugerida