Calculate Average Days Between Won Deals

Calculate Average Days Between Won Deals

Hi Team - how do we calculate the average days between won deals? Can it be done using a formula field or with a custom function? We will use this to create a workflow for reorders or follow up subsequent orders? Thanks in advance