Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here
Oct 28, 2022 12:58 PM
Is there a script or automation I could use - if due date is saturday or sunday, change due date to friday before?
Thanks!
Oct 28, 2022 04:00 PM
You can do this using a few formulas instead of an automation if you’d like.
Here is a formula that could change the date (we’ll call it Calculated Date):
IF({Due date field}="",{Due date field},DATEADD({Due date},
SWITCH(WEEKDAY({Due date field}), 0, -2, 6, -1, 0),'days'))
If you’d like to do it with automation to update the existing due date field automatically, you could do it a few ways:
With a helper column in your table using the field you just created above and one additional helper column (we’ll call this Date Check)
IF({Due date field}={Calculated date},"Yes","No")
The benefits to using the additional columns (3 total: Your original Due Date, Calculated Date, & Date Check) is that it limits the need for addition views that an automation that would be dependent on it to run successfully. Additionally, this achieves the same process if you wanted to use a script, just a bit easier.
Hopefully that helps!