Is it possible to create a formula to obtain the birth date from an age?
Age = 14d, 3m, 55y
Today = 13/01/2021
Birthdate = ?
Is it possible to create a formula to obtain the birth date from an age?
Age = 14d, 3m, 55y
Today = 13/01/2021
Birthdate = ?
With a date in A1 and an age-string in B1 like:
First enter the following User Defined Function in a standard module:
Option Explicit
Public Function BirthDay(d As Date, age As String) As Date
Dim v As String, arr, tDate As Date
v = Replace(age, "y", "")
v = Replace(v, "m,", "")
v = Replace(v, "d,", "")
arr = Split(v, " ")
tDate = DateAdd("d", -arr(0), d)
tDate = DateAdd("m", -arr(1), tDate)
BirthDay = DateAdd("yyyy", -arr(2), tDate)
End Function
and in C1 enter:
=birthday(A1,B1)
Format C1 as you require. Here is an example with UK formatting:
EDIT#1:
To check the answer, we can use the DATEDIF() function. In D1 enter:
=DATEDIF(C1,A1,"y") & " years, " & DATEDIF(C1,A1,"ym") & " months, " & DATEDIF(C1,A1,"md") & " days"
which re-constructs the age-string in B1. 30 September 1965 makes sense intuitively:
(US format above)
Try this formula in cell E2 (in my example):
=A2-(B2*365.25+C2*30.4375+D2)-1