https://www.uscis.gov/green-card/green-card-processes-and-procedures/child-status-protection-act-cspa
“
If you are a family preference (including VAWA self-petition), employment-based preference, or diversity visa (DV) applicant, calculate your CSPA age by subtracting the number of days your petition was pending (pending time) from your age on the date an immigrant visa becomes available to you (age at time of visa availability). However, you must remain unmarried in order to qualify.
The formula for calculating CSPA is: