Forum Discussion
calculating dob for daycare list when child isn't born yet
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
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)
5 Replies
- BBacon621Copper Contributorthank you that worked!
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)")
- BBacon621Copper ContributorBoth 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 😞
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)")