Can someone help me create a textblaze to change dob in mm/dd/yyyy to age in years and months?
Hi @amy_prawalsky,
Welcome to the Blaze forum ![]()
I tried to create a snippet doing that. Let me know if it serves your use case.
Use text field
Enter DoB: {formtext: name=birthday; default=06/21/1986}
{dob_date=datetimeparse(birthday, "MM/DD/YYYY")}{current_date={time: YYYY-MM-DD}}{years=datetimediff(dob_date, current_date, "Y")}{months_total=datetimediff(dob_date, current_date, "M")}{months=remainder(months_total, 12)}
Age: {=years} years and {=months} months
Use date picker
Enter DoB: {formdate: MM/DD/YYYY; name=birthday; default=1986-06-21}
{dob_date=datetimeparse(birthday, "MM/DD/YYYY")}{current_date={time: YYYY-MM-DD}}{years=datetimediff(dob_date, current_date, "Y")}{months_total=datetimediff(dob_date, current_date, "M")}{months=remainder(months_total, 12)}
Age: {=years} years and {=months} months