KeyRoutines
StepFreedate.subtract

Subtract days or hours from a date in a Windows routine

Subtract from date moves a date back in time by an amount you choose. With the date left empty it counts back from now, so "30 days ago" takes one step.

How it works

  • Set the starting date (empty means now), how many, and the unit, from seconds to years.
  • Calendar units work in this computer's time zone, so going back a day keeps the local time of day.
  • Months and years must be whole numbers; going back a month from March 31 lands on the last day of February.

Routines that use it

Clear old downloads

Get the date 30 days ago and, while going through List files, recycle anything older than it.

Last week's report name

Subtract 7 days, format it, and open the matching file with Open file or folder.

Yesterday's folder

Subtract 1 day and zip that day's folder with Zip files.

Settings

SettingWhat it does
DateThe date to start from. Keep empty for now.
AmountHow many.
UnitOf what.

Good to know

  • Months and years only take whole numbers.

Questions

How do I get yesterday's date in a routine?
Use Subtract from date with the date empty, amount 1 and unit days, then Format date to write it as text.
What is March 31 minus one month?
The last day of February. The step keeps month ends on the month's last day.

Pairs well with

Build this routine in KeyRoutines

Free from the Microsoft Store for Windows 11 and 10. Pro is a one-time upgrade.