The formula for calculating COGS is: \[ \text{COGS} = \text{Beginning Inventory} + \text{Purchases during the period} - \text{Ending Inventory} \] This calculation provides a clear view of the direct costs associated with the production of goods sold within a specific period.