Social Media
Headline
Place
Post
Mention
Link
Twitter
Dec 6, 2021
NotionHQ
Post Outline
THE SAVINGS CALCULATOR
The savings calculator determines how many months into the future it will take to save for a particular item. If there is no Start date applied, the End formula will calculate from today's date until Start is filled.
Properties
- Start: date property
- Save per Month: number property
- Cost: number property
End: formula property
if(empty(prop("Start")), dateSubtract(dateSubtract(dateAdd(now(), prop("Cost") / prop("Save per Month"), "months"), hour(now()), "hours"), minute(now()), "minutes"), dateAdd(prop("Start"), prop("Cost") / prop("Save per Month"), "months"))
Formula breakdown
Statement 1: Make prediction for approximate end date from today if Start property is empty. Also ensure that the resulting date has time “12:00am.”
- if(empty(prop("Start")),
- If the Start property is empty …
- dateSubtract(dateSubtract(dateAdd(now(), prop("Cost") / prop("Save per Month"), "months"), hour(now()), "hours"), minute(now()), "minutes")
- Divide Save per Month and Cost …
- dateSubtract(dateSubtract(dateAdd(now(), prop("Cost") / prop("Save per Month"), "months"), hour(now()), "hours"), minute(now()), "minutes")
- Then, add the result of 2. to today’s date in the value of months …
- dateSubtract(dateSubtract(dateAdd(now(), prop("Cost") / prop("Save per Month"), "months"), hour(now()), "hours"), minute(now()), "minutes")
- Then, subtract the hour of now from the date resulting in 3.
- dateSubtract(dateSubtract(dateAdd(now(), prop("Cost") / prop("Save per Month"), "months"), hour(now()), "hours"), minute(now()), "minutes")
- Then, subtract the minute of now from the date resulting in 3.
Statement 2: Make prediction for end date from Start property. This is the false condition, or when the above statement does not apply.
- dateAdd(prop("Start"), prop("Cost") / prop("Save per Month"), "months"))
- Divide Save per Month and Cost, and add the result to Start date in the value of months.
WHY CONVERT DATE TO 12:00AM?
It is good practice to convert date calculations from now(), or today, into dates with a 12:00am time. The now() function includes today’s time, so any addition or subtraction to now() will have a time. 12:00am can indicate that the date spans the entire 24 hour day.
You can also format a date to only show the date without the time.
- ex. formatDate(prop(“Date”), “MM/DD/YYYY”)
However, this will result in a text property and NOT a date that can be viewable in a calendar.
SAVINGS TRACKER DATABASE
The Track Savings database allows the user to add new cards for every input amount into a savings item. Upon clicking a new card, the monthly amount assigned to the item will automatically be added.
- Added property: Amount Saved: rollup property
ADJUSTED END DATE FORMULA
Determine what the adjusted end date is from the amount of money saved. This is a separate formula in the Savings Calculator using the above rollup property.
Adjusted End Formula
dateSubtract(dateSubtract(dateAdd(now(), (prop("Cost") - prop("Amount Saved")) / prop("Save per Month"), "months"), hour(now()), "hours"), minute(now()), "minutes")