Here's the formula:
Specific Gravity = Density of Substance / Density of Reference Substance
Commonly, the reference substance is water at 4°C.
Important Note: This formula assumes that the density of the reference substance is known. If the density of the reference substance is not known, then you can't calculate the specific gravity.