SOLVED

calculating dob for daycare list when child isn't born yet

Copper Contributor

I have a spreadsheet that calculates the DOB of a child based on todays date and DOB - what do I do if it's also a waiting list because the child isn't born yet? I get a #NUM! error. I'm thinking it would be an IF statement but not sure how to get it to say "0" in the DOB field and change to the right age once the child is born????

 

this is my formula so far:

=DATEDIF(B2,TODAY(),"y")&" year(s), "&MOD(DATEDIF(B2,TODAY(),"m"),12)&" month(s)"

 

gives me the correct age in years & months - if the child isn't born yet I'd like it to say "0 years, 0 months" and then change once the child is born to say "0 years, 0 months, 1 day" etc. Is that even possible? It's okay if it uses years, months, days for all the children if it has to be all or nothing...

 

please help - I love excel but don't understand a lot about manipulating complex formulas

 

Beth

5 Replies

@BBacon621 

For example:

 

=IF(B2="","Not born yet",DATEDIF(B2,TODAY(),"y")&" year(s), "&MOD(DATEDIF(B2,TODAY(),"m"),12)&" month(s), "&TODAY()-EDATE(B2,DATEDIF(B2,TODAY(),"m"))&" day(s)")

 

or

 

=IF(B2="","0 years, 0 months, 0 days",DATEDIF(B2,TODAY(),"y")&" year(s), "&MOD(DATEDIF(B2,TODAY(),"m"),12)&" month(s), "&TODAY()-EDATE(B2,DATEDIF(B2,TODAY(),"m"))&" day(s)")

Both work to give me the year, month, days BUT neither work if the child isn't born yet. If the child isn't born till lets say October 13, 2022 then I'm still getting the #NUM! error :(

@BBacon621 

How do you know the DOB if the child isn't born yet? Anyway, try

 

=IF(B2>TODAY(),"0 years, 0 months, 0 days",DATEDIF(B2,TODAY(),"y")&" year(s), "&MOD(DATEDIF(B2,TODAY(),"m"),12)&" month(s), "&TODAY()-EDATE(B2,DATEDIF(B2,TODAY(),"m"))&" day(s)")

best response confirmed by BBacon621 (Copper Contributor)
Solution

@BBacon621 , just wrap your existing formula with the IFERROR formula,

 

=IFERROR(DATEDIF(B2,TODAY(),"y")&" year(s), "&MOD(DATEDIF(B2,TODAY(),"m"),12)&" month(s)",0)

thank you that worked!
1 best response

Accepted Solutions
best response confirmed by BBacon621 (Copper Contributor)
Solution

@BBacon621 , just wrap your existing formula with the IFERROR formula,

 

=IFERROR(DATEDIF(B2,TODAY(),"y")&" year(s), "&MOD(DATEDIF(B2,TODAY(),"m"),12)&" month(s)",0)

View solution in original post