Topic 5568319
For the current version of the reference client, the closest feature that you can utilize is "manual pruning".
Setting "prune=1" in your config or adding --prune as a command line arg will enable that.
With that enabled, you can use pruneblockchain command which supports epoch timestamp as arg. (set it to a date 2 years ago)
But you'll have to do it periodically since it's manual.

Here's the documentation of that command: bitcoincore.org/en/doc/30.0.0/rpc/blockchain/pruneblockchain

Good idea. If it's combined with bash script and system service, the prune process also can be automated. Just make sure date and time on your system is properly synced.