<aside> <img src="/icons/graduate_yellow.svg" alt="/icons/graduate_yellow.svg" width="40px" /> Explanation
We will use the lets
formula to create and reference multiple variables without repeating calculations and keeping our formula clean.
Create a formula to calculate the number of years:
lets(
age_years, dateBetween(now(), prop("Birth Date"), "years")
)
Calculate the number of months remaining based on the latest date of years:
lets(
age_years, dateBetween(now(), prop("Birth Date"), "years"),
new_date_1, dateAdd(prop("Birth Date"), age_years, "years"),
age_months, dateBetween(now(), new_date_1, "months")
)
Calculate the number of weeks remaining based on the latest date of months:
lets(
age_years, dateBetween(now(), prop("Birth Date"), "years"),
new_date_1, dateAdd(prop("Birth Date"), age_years, "years"),
age_months, dateBetween(now(), new_date_1, "months"),
age_weeks, dateBetween(now(), new_date_2, "weeks"),
new_date_3, dateAdd(new_date_2, age_weeks, "weeks")
)
Calculate the number of days remaining based on the latest date of weeks:
lets(
age_years, dateBetween(now(), prop("Birth Date"), "years"),
new_date_1, dateAdd(prop("Birth Date"), age_years, "years"),
age_months, dateBetween(now(), new_date_1, "months"),
age_weeks, dateBetween(now(), new_date_2, "weeks"),
new_date_3, dateAdd(new_date_2, age_weeks, "weeks"),
age_days, dateBetween(now(), new_date_3, "days")
)
Displaying the numbers of years, months, weeks, and days:
lets(
age_years, dateBetween(now(), prop("Birth Date"), "years"),
new_date_1, dateAdd(prop("Birth Date"), age_years, "years"),
age_months, dateBetween(now(), new_date_1, "months"),
new_date_2, dateAdd(new_date_1, age_months, "months"),
age_weeks, dateBetween(now(), new_date_2, "weeks"),
new_date_3, dateAdd(new_date_2, age_weeks, "weeks"),
age_days, dateBetween(now(), new_date_3, "days"),
"Your age is: " + age_years + " years, " + age_months + " months, " + age_weeks + " weeks, " + " and " + age_days + " days"
)
Styling the formula:
lets(
age_years, dateBetween(now(), prop("Birth Date"), "years"),
new_date_1, dateAdd(prop("Birth Date"), age_years, "years"),
age_months, dateBetween(now(), new_date_1, "months"),
new_date_2, dateAdd(new_date_1, age_months, "months"),
age_weeks, dateBetween(now(), new_date_2, "weeks"),
new_date_3, dateAdd(new_date_2, age_weeks, "weeks"),
age_days, dateBetween(now(), new_date_3, "days"),
"Your age is:" + "\\n" + style(style(age_years, "c") + " years" + "\\n" + style(age_months, "c") + " months " + "\\n" + style(age_weeks, "c") + " weeks" + "\\n" + style(age_days, "c") + " days", "b")
)
</aside>
I'm a Social Media Manager and Notion Creator with +5 years of experience. 💻
Whether you're an individual or a business, I will help you become the most organized and productive.
If you have any questions, you can reach out to me on X (Twitter) or LinkedIn.
<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/226df777-5c38-425b-939b-e95aa4ebba76/62c9d51e94890221ddd176a5.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/226df777-5c38-425b-939b-e95aa4ebba76/62c9d51e94890221ddd176a5.png" width="40px" /> Gumroad
</aside>
<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2cf661aa-cd0b-400c-ae23-033a85d24a58/logo-black.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2cf661aa-cd0b-400c-ae23-033a85d24a58/logo-black.png" width="40px" /> X (Twitter)
</aside>
<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c2da6e8c-6c37-43fe-8445-5a4567aca819/linkedin.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c2da6e8c-6c37-43fe-8445-5a4567aca819/linkedin.png" width="40px" /> LinkedIn
</aside>