How to trim history

Hi, I am trying to figure out how to trim my history. For example, don’t save history more than x days. But I can’t figure out how to do it.